I am writing test cases for my first Clojure project. Here, I want the test to fail if the value of ":meat" is empty :
(deftest order-sandwich
(let [response {:meat "" :bread "yes" :add-on "lettuce"}]
(is (= (:bread response) "yes"))
(is (not (nil? (:meat response))))))
But my test runs successfully (returning "nil") .
Anybody know why this happens? Is there a better way to do this?
I thank you in advance!!
An empty String is not
nil
:You want to test if it's empty, not
nil
, which can be done usingseq
orempty?
(among other ways):