This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-24
Channels
- # aws (7)
- # aws-lambda (3)
- # beginners (65)
- # boot (43)
- # cider (7)
- # cljs-dev (12)
- # cljsrn (15)
- # clojure (284)
- # clojure-austin (32)
- # clojure-brasil (4)
- # clojure-dusseldorf (4)
- # clojure-germany (1)
- # clojure-italy (40)
- # clojure-spec (21)
- # clojure-uk (69)
- # clojurescript (97)
- # core-async (11)
- # cursive (19)
- # data-science (1)
- # datascript (6)
- # datomic (30)
- # dirac (2)
- # emacs (4)
- # events (2)
- # fulcro (76)
- # graphql (38)
- # juxt (1)
- # lein-figwheel (1)
- # leiningen (6)
- # luminus (4)
- # lumo (13)
- # mount (4)
- # off-topic (24)
- # om (28)
- # onyx (32)
- # other-languages (1)
- # parinfer (40)
- # pedestal (1)
- # portkey (47)
- # re-frame (21)
- # reagent (4)
- # ring (4)
- # ring-swagger (3)
- # rum (1)
- # shadow-cljs (115)
- # spacemacs (5)
- # sql (14)
- # unrepl (1)
- # yada (3)
hey @tolitius,
I have a question regarding unit testing.
we have a project that it's api is basically core.async/chan
nels. you push a message on one side, and pull the result on another. so far so good. now, as one could expect, each test does exactly this (>!! c-in msg) (process) (<!! c-out) (assertions msg)
.
for that, we used (use-fixtures :each common-mocks-fixture)
where common-mocks-fixture
is swapping the kafka consumer and producer of the service with just a map with a channel. as such:
(defn common-mocks-fixture [test-fn] (start-mocks) (test-fn) (mount/stop)
`(defn start-mocks []
(->
(only common-test-states) ; this is just a set of states
(mount/swap-states common-test-swaps) ;see below
start))`
`(def common-test-swaps
{#'kc/alglaunches-mi-consumer {:start (fn [] {:channel (chan 1)})
:stop #(close! (:channel kc/alglaunches-mi-consumer))}
#'kp/pre-matches-producer {:start (fn [] {:channel (chan 1)})
:stop #(close! (:channel kp/pre-matches-producer))}})`
This theoretically should work, but still. if a test calls (process)
that leaves a message in the outgoing channel, the next test fails. any clue what are we doing wrong?
hey @ido (I am driving: i.e. typing slow), but why do you have anonymous :stop
functions? why not:
:stop (close! (:channel kc/alglaunches-mi-consumer))
:stop (close! (:channel kp/pre-matches-producer))
by quickly looking at it I suspect these channels are simply don't close between tests