hello everyone, I see that version 0.8.0
introduced `:duct.profile/test`
but I dont see any mention on how to use it, what it enables me to do ?
ideally id like to create a test.edn
somewhere and I when ran lein test
that config gets merged with the dev one.
Is there something like that already implemented or ill need to write a fixture of my own, parse both edn files, merge then, then use ig/init
passing that configuration?
if you are you're initiating the configuration in your fixture you can add the :duct.profile/test
key to the initializing function
not sure if I got you, a little bit more context: I was using 0.7.0, upgraded to 0.8.0, what I need to modify for it to work?
(duct noob here)
You could use integrant.repl
to manage it for you in the tests.
(defn- read-config []
(duct/read-config (io/resource "my-app/config.edn")))
(defn init-system []
(duct/load-hierarchy)
(integrant.repl/set-prep! #(duct/prep-config (read-config) [:duct.profile/test])) ;; <<<<< TEST PROFILE GOES HERE
(integrant.repl/go))
(defn halt-system []
(integrant.repl/halt))
(defn once-fixture [tests]
(init-system)
(tests)
(halt-system))
(use-fixtures :once once-fixture)
@kevin.van.rooijen just out of curiosity, why not use ig/init
and ig/halt!
?
it seems a bit strange to me to use code designed to be used in the repl in a test configuration, thats why I ask
You can also do that. But you'll have to keep track of the state yourself in order to halt the system. Which is also fine
fair point!
what would you do? an atom?
Yes, I'd use an atom
once again, thanks 🙂
👍
That would merge the test profile into your main config.edn
thanks 🙂