This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-17
Channels
- # adventofcode (3)
- # announcements (1)
- # babashka (25)
- # beginners (55)
- # calva (12)
- # cider (40)
- # clj-kondo (13)
- # clojure-australia (2)
- # clojure-dev (11)
- # clojure-europe (67)
- # clojure-france (6)
- # clojure-nl (16)
- # clojure-uk (9)
- # clojuredesign-podcast (9)
- # clojurescript (17)
- # conjure (7)
- # cursive (3)
- # datomic (3)
- # emacs (8)
- # figwheel-main (7)
- # fulcro (21)
- # google-cloud (21)
- # graphql (8)
- # helix (1)
- # honeysql (32)
- # instaparse (2)
- # jobs (2)
- # jobs-discuss (2)
- # meander (80)
- # mount (1)
- # off-topic (25)
- # pathom (31)
- # polylith (1)
- # rdf (24)
- # re-frame (21)
- # reagent (29)
- # releases (1)
- # remote-jobs (1)
- # shadow-cljs (16)
- # slack-help (6)
- # sql (5)
- # tools-deps (23)
- # uncomplicate (2)
- # wasm (2)
- # xtdb (4)
Hey guys. I’m hand-rolling my own solution for a static site generator. Now I’d like to have multilingual support, I’m wondering what the best way to go about that is. I assume I’ll have to deal with routing eventually, using something like bidi or reitit. What other things should I consider in order to keep things neat? https://gitlab.com/wildwestrom/cljs-tailwind-static/-/tree/personal-site
Hi everyone, I'm looking for something I encountered before (but can't think of the right search terms). What is the website that analyses clojure code and helps you to "fill in the blanks" of the code using core.logic
(?) which is based a haskell's implementation
not core.logic based, but a similar idea, https://borkdude.github.io/re-find.web/
I haven't seen this before, this looks quite useful! I also like the way the examples slowly cycle, that is a really nice touch that I have not seen before.
(let [name (.next list-of-statement)
v (conj [] (->> name (.getName) (.toString)))]
v)
this code can’t return nil because (conj [] …)
will return a vector
empty vector or [nil]
?
Even (conj [] nil)
returns [nil]
, i.e. a vector with one element (which is nil
), so I don't see how that expression you gave can possibly return an empty vector.
is it possible that this peace is working in bigger context? I’m expecting you are trying to append an element to vector in a loop
is list-of-statements an iterator? If so you could use iterator-seq
to turn it into a seq which is a lot easier to work with.
Then you can use more standard/idiomatic clojure.
(do (defn db-values [] (iterator-seq all-db-vals-iterator))
(defn db-value-name [db-value] (-> db-value (.getName) str))
(defn db-value-names (->> (db-values)
(map db-value-name))))
Is list-of-statement
a Java Iterator object?
See comment above about iterator-seq
which looks like good recommendation
Hi there. Can anyone give me a recommendation on what good mock/spy/stub testing library to use in Clojure/Script? Thanks in advance.
Did a quick googling and there's https://github.com/alexanderjamesking/spy but I'm just wondering what other good library I might miss out on 🙂
You can also use with-redefs fn's from the standard library to mock out functions I do this in tests to avoid a db hit and return the rows I need for my test if your not aware of these functions.
the best way (imho) to get advantage from mocking/stubbing/spying is to make such ability first-class citizen in your application. libraries for dependency injections will help a lot there. You could have a look at integrant for example.
Thanks guys. I just need a way to do some simple testing for a small project I'm working in. At this scale I don't think I'd need something like Integrant, but thanks regardless 🙂
Good day. I'm curious is there any guide about the argument position convention of clojure.core? I know some excerpts are: • Object as the first argument • Sequence as the last argument But every time I confuse where to put a numeric argument and also the last bullet not 100% truth.
some info about that topic - https://groups.google.com/u/2/g/clojure/c/iyyNyWs53dc not complete answer thou
thank you
Hopefully a quick one: Is there a usual approach for mocking a function to first throw an exception and then return something else? I'm trying to test a catch clause. In mockito I would have done something like andThen ...
like the first invocation would throw and subsequent invocations would return a value?
yes, that's what I'm doing in this particular case.
But having a pattern for returning one value, then another, etc., would be useful. The thing I'm mocking is making a REST call and returning the response, so it's not pure.
In another project, I did this with an atom holding a list and then popped them, but I must have done it wrong, because it's flaky. I'm hoping someone has a tried and true pattern.
Or it's just a feature of clojure.test I'm missing, and I don't have the right terms to google.
clojure test doesn't have any mocking functionality. its just assertions and such. if you're single threaded its possible to use with-redefs
and temporarily replace things with functions that do what you want. if you've got a system engineered where you construct a system graph, you could construct it with subsystems that do what you want
a bit like this https://github.com/kelveden/clj-wiremock
Ah, yeah, that's what I use in Scala (the Java version of that). I always forget I've got the whole JVM world to draw on...
there's no access to the jvm from scala?
Yes, of course, but Clojure is so different that it just doesn't occur to me as easily. I just forget!
(wmk/with-stubs
[{:req [:GET (str "/tenant/v1/" rsc-tenant-id)] :res [200 {:body (utils/map->string {:tenantCode rsc-tenant-code})}]}]
(->> (generate-email-payload rsc-investigations rsc-tenant-code 12 app-config)
(expect (assoc rsc-email-configuration :body email-body))))))
Right, so I can make the first attempt return some non-200 (404) and then return a 200. Got it. Looks like what I want. Thank you!
I have a list of dictionaries as such:
[{:id 1 :key 1 :value 1}
{:id 1 :key 0 :value 0}
{:id 2 :key 1 :value 1}
{:id 2 :key 0 :value 0}]
and id like to group this list by id as such:
[{:id 1 :attributes [{:key 1 :value 1} {:key 0 :value 0}]}
{:id 2 :attributes [{:key 1 :value 1} {:key 0 :value 0}]}]
This wouldnt be too hard in python but im scratching my head for how to write this in clojure 😅