Hi all, new to Litestar and struggling a bit. I'm trying to figure out if there's a way to force tests to roll back their db changes at completion, in spite of SQLAlchemyPlugin being set to before_send_handler="autocommit". I'm using Postgres running in a testcontainer.
I've successfully set up a test db session fixture that uses Postgres savepoints to roll back, which works great as long as the tests update the db directly, through that session. The problem seems to be that when I invoke an actual Litestar route, it uses a different db session, one that actually does commit (provided by the SQLAlchemyPlugin?). I'm curious if the solution is to make the plugin provide the test session explicitly, and if so how that's done. I've spent a day or so wrestling with this and am a bit over my head.
I'd be most grateful for any ideas! Two things I'd rather not do if I don't have to, but will if I do have to:
(1) Drop and recreate the entire starting database for each test, which is what the litestar-fullstack example seems to do;
(2) Duplicate the app creation logic in the tests with a slightly different plugin configuration.
Thanks for any help!