Skip to content

Instantly share code, notes, and snippets.

@augustl
Last active November 22, 2017 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save augustl/4a679dc95847db4434d0e7348651224f to your computer and use it in GitHub Desktop.
Save augustl/4a679dc95847db4434d0e7348651224f to your computer and use it in GitHub Desktop.
;; [org.clojure/clojure "1.8.0"]
;; [org.clojure/clojurescript "1.9.946"]
;; [org.clojure/core.async "0.3.465"]
(ns huffda.expectations-basics-test
(:require [clojure.test :refer [deftest testing is async]]
[huffda.expectations :as expec]
[cljs.core.async :refer [chan <! >! put! close! alts! timeout promise-chan]])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
;; Works fine
(deftest expectations-basics
(testing "should work"
(async done
(go
(let [[db err] (<! (expec/create-memory-database))]
(<! (expec/add-expectation db {:key "my-expec-1"}))
(is (not (<! (expec/is-fulfilled db "my-expec-1"))))
(<! (expec/fulfill-expectation db "my-expec-1")))
(done)))))
;; Fails with:
;; ERROR in (expectations-basics) (Error:NaN:NaN)
;; expected: (<! (expec/is-fulfilled db "my-expec-1"))
;; actual: #object[Error Error: <! used not in (go ...) block]
(deftest expectations-basics
(testing "should work"
(async done
(go
(let [[db err] (<! (expec/create-memory-database))]
(<! (expec/add-expectation db {:key "my-expec-1"}))
(is (not (<! (expec/is-fulfilled db "my-expec-1"))))
(<! (expec/fulfill-expectation db "my-expec-1"))
(is (<! (expec/is-fulfilled db "my-expec-1"))))
(done)))))
;; Also fails
(deftest expectations-basics
(testing "should work"
(async done
(go
(let [[db err] (<! (expec/create-memory-database))]
(<! (expec/add-expectation db {:key "my-expec-1"}))
(is (<! (expec/is-fulfilled db "my-expec-1"))))
(done)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment