O'Reilly logo
  • Joerg Schmuecker thinks this is interesting:

(deftest test-app (let [url "http://example.com/post" id "test" path (str "/links/" id)] (testing "creating a link" (let [response (app (mock/request :post path url))] (is (= 200 (:status response))) (is (= path (:body response))))) (testing "visiting a link" (testing "when the link exists" (let [response (app (mock/request :get path))] (testing "returns a 302" (is (= 302 (:status response))) (testing "with the correct location" (is (= url (get-in response [:headers "Location"]))))))) (testing "when the link does not exist" (let [response (app (mock/request :get "/links/nothing"))] (testing "returns a 4...

From

Cover of Professional Clojure

Note

Again, this test only works if you reload the application.clj after each run. It doesn't reset the app, so the test for insertion will fail.