testing

Testing tools, testing philosophy & methodology...
plexus 2020-05-20T17:06:29.021Z

(defmacro will
  "Variant of [[clojure.test/is]] that gives the predicate a bit of time to become
  true."
  [expected]
  `(loop [i# 0]
     (if (and (not ~expected) (< i# 10))
       (do
         (Thread/sleep 10)
         (recur (inc i#)))
       (t/is ~expected))))

plexus 2020-05-20T17:06:52.021200Z

(will (= [{:whoami {:id :abc :hello :world}}] (vals @state)))

plexus 2020-05-20T17:07:24.021500Z

fun little helper for eventually consistent tests