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

(let [id-urls {"a" "http://example.com/a" "b" "http://example.com/b" "c" "http://example.com/c"} ids (doseq [[id url] id-urls] (create-link stg id url)) links (list-links stg)] (testing "in a map" (is (map? links)) (testing "equal to the links we created" (is (= id-urls links)))))))

From

Cover of Professional Clojure

Note

Unfortunately, this doesn't work as the Storage is not cleared before this test case. This means we either need to pass in a generator function into this where we can recreate instances of the storage or add a function which allows to clear a storage.

(defn is-valid-storage-fixed
  "Returns a list of functions that should be executed in order to
test the different aspects of a working Storage.

This allows to reset the Storage between the different tests."
  []
  [(fn [stg]
     (let [url "http://example/clojurebook"
           id "book"]
       (testing "can store and retrive a link"
         (testing "create-link returns the id&qu...