-
-
Save scotdalton/a5302b5687b34ddf621b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bigtalk.core | |
(:require [compojure.core :refer :all] | |
[compojure.route :as route] | |
[bigtalk.actions :as actions]) | |
(:gen-class)) | |
(defn root | |
"Root request handler" | |
[request] | |
{:status 200 | |
:headers {"Content-Type" "text/html"} | |
:body "Talk Big!"}) | |
(defroutes app-routes | |
(GET "/" request (root request)) | |
(route/not-found "Çok üzgünüz, yanliş bir şey!")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bigtalk.core-test | |
(:require [clojure.test :refer :all] | |
[ring.mock.request :as mock] | |
[bigtalk.core :refer :all])) | |
(defn request [method uri] | |
(app-routes (mock/request method uri))) | |
(deftest test-app-routes | |
(testing "Root request should respond with a successful response" | |
(let [method :get uri "/"] | |
(is (= 200 (:status (request method uri)))) | |
(is (= {"Content-Type" "text/html; charset=utf-8"} | |
(:headers (request method uri)))) | |
(is (= "Talk Big!" (:body (request method uri)))))) | |
(testing "Invalid request should respond with a 404" | |
(let [method :get uri "/invalid"] | |
(is (= 404 (:status (request method uri)))) | |
(is (= {"Content-Type" "text/html; charset=utf-8"} | |
(:headers (request method uri)))) | |
(is (= "Çok üzgünüz, yanliş bir şey!" (:body (request method uri))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment