Hi all! Does anybody here have a favourite hook/way for closing a connection that has to be shared throughout the whole test?
yeah I am very familiar with those. The problem I am trying to solve is to start something (an embedded postgres instances - or a docker container for that matter) before the first test is run and stop that after the last test is run. When watching this really improves the runtime. I am relying now on dynamic bindings/atoms but I was exploring if kaocha adds hooks for that use case. Leaving it here in case others here have solved the same problem before or have advice, thanks!
for this i would recommend using component (or a similar DI library).
at a previous job, we had a set up where there was a *system* var in the main test entrypoint (all test files required it for the helper functions), and during load it would be populated with the database connections, and then we'd call (component/up *system*) and (component/down *system*) in a macro that wrapped other calls
yeah we use mount- we are doing that right now, the pre-load / post-load / wrap-run hook is what we are using but they are not "per full run" - they are per test
(or per suite)
i think kaocha supports this with the pre-run hook: https://cljdoc.org/d/lambdaisland/kaocha/1.91.1392/doc/10-hooks#config--test-plan-hooks
oh, you mean you're already using kaocha's pre-load hook? my apologies
yeah - we are already using that and it's not "global" if that makes sense
OK. I don't know about that. Are you familiar with fixtures? That is per test namespace (I think)
The whole test as in a single file or all test files?
Or just a single test inside a test file?
I basically want to close my db connection at the end of the tests