I’m struggling with making a test setup using mount state handling library. https://github.com/tolitius/mount#swapping-alternate-implementations
I want to be able to:
start my app in the repl
test manually
run clojure tests using a different database / schema
continue testing manually after the tests
Based on the documentation, I should be able to mount/start-with-states
and then mount/stop
would return the implementations to the original ones. Not so.
Furthermore, I don’t want to stop my dev time database connection during the tests.
so it looks like this has been a source of discussion earlier many times
I came up with something like this
(let [running-states (mount/running-states)]
(when (seq running-states)
(mount/stop))
(mount/swap-states {#'env/config {:start read-test-config}})
(mount/start-with-args {:config {:silent? true}})
(run-tests)
(mount/stop)
(when (seq running-states)
(mount/start (map symbol running-states))))
which
1. stops the currently running state
2. starts the application with config swapped out
3. runs the tests
4. stops the test states
5. starts any states that were running before the testswhy not
* start my app in the repl * test manually >> restart a database component with a different schema * run clojure tests using a different database / schema >> restart a database component ("normally") * continue testing manually after the tests