sql

Vitaly Samigullin 2024-03-03T15:13:05.418699Z

Q. regarding transaction rollback with next.jdbc in my integration tests. I've got a Clojure backend using ring, jetty and mount (alternative to component). In my https://github.com/pilosus/dienstplan/blob/663ca87c40e5bf77cb5ed61099cdd7ad241a4170/test/dienstplan/db_test.clj#L29 I use a transaction https://github.com/pilosus/dienstplan/blob/00026fa115a07c982f04bd0b67bd7f0f31e644fc/test/dienstplan/fixture.clj#L55 with next.jdbc.transaction/*nested-tx* :ignore binding so that I can rollback the outermost transaction during the test teardown. It works well in this scenario. In my integration tests though the whole app gets started, including jetty server, and my db rollback fixture doesn't work anymore. I'm not quite sure what's happening, but assume that it's somehow related to the Jetty server spawning multiple threads to handle connections, and my next.jdbc.transaction/*nested-tx* binding being overridden. I do have a workaround with the https://github.com/pilosus/dienstplan/blob/663ca87c40e5bf77cb5ed61099cdd7ad241a4170/test/dienstplan/fixture.clj#L82. But I find it a bit of an overkill for current tests that I have. What can I do to get my DB rollback fixture work in integration tests?

Vitaly Samigullin 2024-03-04T18:34:23.222329Z

Didn't know about bound-fn* . Will give it a try. Thanks!

2024-03-03T19:02:50.663029Z

Wrap your handler in a call to bound-fn* when starting

2024-03-03T19:04:25.474679Z

The ultimate handler being passed to ring-jetty