duct

plins 2020-08-17T20:09:23.347200Z

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?

kwrooijen 2020-08-17T20:15:36.348400Z

if you are you're initiating the configuration in your fixture you can add the :duct.profile/test key to the initializing function

plins 2020-08-17T20:17:07.349500Z

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?

plins 2020-08-17T20:17:24.350Z

(duct noob here)

kwrooijen 2020-08-17T20:18:03.350500Z

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)

plins 2020-08-18T20:42:48.351500Z

@kevin.van.rooijen just out of curiosity, why not use ig/init and ig/halt! ?

plins 2020-08-18T20:43:19.351700Z

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

kwrooijen 2020-08-18T20:45:09.351900Z

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

plins 2020-08-18T20:46:50.352100Z

fair point!

plins 2020-08-18T20:47:17.352300Z

what would you do? an atom?

kwrooijen 2020-08-18T20:48:11.352500Z

Yes, I'd use an atom

plins 2020-08-18T20:48:29.352700Z

once again, thanks 🙂

kwrooijen 2020-08-18T20:48:36.352900Z

👍

kwrooijen 2020-08-17T20:19:29.351Z

That would merge the test profile into your main config.edn

plins 2020-08-17T20:22:54.351400Z

thanks 🙂