Created
September 20, 2012 19:29
-
-
Save gtrak/3757861 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
(defn assert-only-expected-keys | |
"Make sure that there are no extra keys in the item" | |
[keyset item] | |
(mapv (fn [k] (is (keyset k) (str k " is not one of " keyset))) | |
(keys item)) | |
item) | |
(defn assert-all-expected-keys | |
"Make sure that every expected key exists in the item" | |
[keyset item] | |
(let [ks (into #{} (keys item))] | |
(mapv (fn [k] (is (ks k) (str k " is not one of " ks))) | |
keyset)) | |
item) | |
(defn assert-correct-keys | |
"Make sure the keys are as expected (no recursion)" | |
[keyset item] | |
(assert-only-expected-keys keyset item) | |
(assert-all-expected-keys keyset item)) | |
(deftest test-list-job | |
(let [{:keys [status body]} (test-core/test-request :get (build-uri ...)) | |
items (:items body)] | |
(is (= status 200)) | |
(is (map? body)) | |
(check-coll items) | |
(mapv (partial assert-correct-keys #{:uri :createdAt :executedAt :comment :status}) items))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment