Last active
December 10, 2015 16:39
-
-
Save quux00/4462372 to your computer and use it in GitHub Desktop.
Unit test snippet for using timeout-channel from go-lightly library
This file contains hidden or 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
(testing "timeout channel with other channels" | |
(let [ch1 (channel) | |
ch2 (channel) | |
tch (timeout-channel 250) | |
fnext-msg (partial select ch1 ch2 tch)] | |
(go (test-routine ch1 1)) | |
(go (test-routine ch1 2)) | |
(loop [msg (fnext-msg)] | |
(when-not (= msg :go-lightly/timeout) | |
(is (some #{1 2} [msg])) | |
(recur (fnext-msg))))) | |
(stop))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment