integrant

Sam 2024-07-16T13:02:47.156609Z

Could I get some guidance on testing with integrant? I received some advice before:

You can create a test system in a fixture or in a test. Since the config is a plain map, you can easily create sub-systems and systems with mocks.
but I don't understand it. I'm trying to get it to work now, but in the end I only understand how to access components through other components or through integrant.repl, neither which is mentioned (and I get that they're not the right things here). Trying to get this to work:
(deftest test-system-online?
  ;;This test should just test the database connection, aka :foo.core/src.
  []
  (ig/init
   ;;Make sure environment is set to dev
   (assoc-in core/config
              [:foo.core/src :environment]
              "dev")
   ;;What happens now? I can access the datasource using system.repl but that makes me a bad boy.
   ))

weavejester 2024-07-16T13:04:16.481769Z

The integrant.core/init function returns the system.

weavejester 2024-07-16T13:05:16.771179Z

(let [system (ig/init dev-config)]
  (try ;; test
    (finally (ig/halt! system))))

Sam 2024-07-16T13:05:58.565379Z

Oh, that was extremely easy 😅 Thank you, this got the job done!