This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-09
Channels
- # announcements (1)
- # aws-lambda (3)
- # babashka (6)
- # beginners (91)
- # bristol-clojurians (5)
- # calva (25)
- # chlorine-clover (8)
- # cider (6)
- # clj-kondo (13)
- # cljdoc (10)
- # cljsrn (1)
- # clojure (80)
- # clojure-berlin (6)
- # clojure-europe (29)
- # clojure-nl (4)
- # clojure-spec (18)
- # clojure-uk (51)
- # clojurescript (41)
- # conjure (55)
- # cursive (3)
- # datomic (58)
- # emacs (9)
- # events (1)
- # figwheel-main (2)
- # fulcro (29)
- # graphql (12)
- # helix (4)
- # jobs (4)
- # klipse (8)
- # london-clojurians (1)
- # malli (5)
- # off-topic (13)
- # portal (9)
- # re-frame (30)
- # shadow-cljs (44)
- # spacemacs (7)
- # specter (3)
- # sql (11)
- # tools-deps (71)
- # windows (1)
- # xtdb (10)
Mornin' ๐:skin-tone-2:
Aside from the firestorm burning up California and the out-of-control pandemic, yeah, I guess ๐
Roll on November 3rd. Although we likely won't know the final result for days. Maybe weeks. Argh!
Oh, I'm thinking it's going to be depressing news - no matter who wins - there's a'trouble brewing methinks.
ยกmawningยก
morning
Morning
Hey folks, I started a new contract on Monday (back in Java land for a bit), but a recruiter I have been working with has just sent me a spec for a company looking to hire some Clojure permies. I hope I am not out of line mentioning it in here (I know there is a #jobs), but I do seem to remember a few people mentioning that they were currently on the lookout. Ping me with a DM if anybody wants an intro. Cheers.
I should mention, I wont be asking for or taking any referral fees for this, just thought I would ask in case it helps anybody out.
Hi all, the recording of the following event is now available online: William Parker - Logic programming with clara-rules @ LNDCLJ https://youtu.be/aJbdTP5hL0U
Thanks again for organising it @bruno.bonacci ๐... The talk was interesting!
seems to do what I want, in a test, I can "mock" out a function that calls to an external API
Not necessarily, you will have an orchestrating function that does this:
(-> (call-external-service) a b c)
And your test will do this:
(-> some-map a b c)
Instead of writing code like this:
(defn A [] (println "A") (B))
(defn B [] (println "B"))
Write this:
(defn A [] (println "A"))
(defn B [] (println "B"))
(do (A) (B))
Finally, if you really must do the side effect thing, use a protocol to mock the external service and pass it around. It'll cause you way less headaches, promise. e.g. if you ever turn on parallel tests in eftest.
(defn filter-for-valid-agreement
[policies to app-config]
(first (filter #(ac/query-for-associations (:agreementId %) to app-config) policies)))
the ac/query-for-associations
does a API lookup and returns a map or nil if an assocation is found.
so I redef'ed ac/query-for-associations
to return data that I'm interested in during my test.
it's important to behave the way I expect, i.e., either return the first of policy (that has an associations) or a nil result
a bug was discovered today that didn't take that into account, so I wrote a test specifically for that.
https://cognitect.com/blog/2016/9/15/works-on-my-machine-understanding-var-bindings-and-roots I remember this being more scolding, but it doesn't seem to be now. But yeah, with-redefs is hard.
I'll keep that in mind and see if I can also take into account your suggestions too ๐
https://old.reddit.com/r/Clojure/comments/ble9k4/dont_use_a_protocol_to_make_testing_easier/emo5cjl/ scalding :D
So yeah, use protocols if you're testing stateful functions. Try to pass the results of stateful functions around though instead. Avoid with-redefs always.