This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-15
Channels
- # alda (4)
- # beginners (9)
- # boot (2)
- # cider (56)
- # cljsrn (6)
- # clojure (29)
- # clojure-belgium (2)
- # clojure-gamedev (1)
- # clojure-russia (19)
- # clojure-uk (3)
- # clojurescript (7)
- # core-async (2)
- # datomic (16)
- # hoplon (96)
- # lein-figwheel (4)
- # om (2)
- # om-next (3)
- # other-languages (6)
- # planck (11)
- # reagent (9)
- # rethinkdb (1)
- # ring-swagger (1)
- # spacemacs (1)
Thanks for your answer. The go blocks really are not necessary. I’ve written the following test:
(deftest foo-test
(let [to-chan1 (a/timeout 5000)
foo-chan (foo)
[v1 ch1] (a/alts!! [foo-chan to-chan1])
to-chan2 (a/timeout 100)
[v2 ch2] (a/alts!! [to-chan2 foo-chan])]
(is (not= ch1 to-chan1) "Channel provides a value within 5 seconds.")
(is (= v1 42) "Channel provides 42.")
(is (and (= ch2 foo-chan) (nil? v2))
"Channel closes after providing the first value.")))
But it may block the test thread for up to 5 seconds. Is there any way around that?