Skip to content

Instantly share code, notes, and snippets.

@quux00
Last active December 10, 2015 16:39
Show Gist options
  • Save quux00/4462372 to your computer and use it in GitHub Desktop.
Save quux00/4462372 to your computer and use it in GitHub Desktop.
Unit test snippet for using timeout-channel from go-lightly library
(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