You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bring TestTx helper into rivershared for use in other projects (#814)
I found in another demo project that I wanted to have access to the
`TestTx` helper for tests, but that we weren't exporting it anywhere.
Here, bring it into `rivershared` for easy access everywhere.
I put two variants in for now, the simpler `TestTx` that uses a pool to
`TEST_DATABASE_URL` or `river_test`, and a `TestTxPool` that lets you
inject your own pool. The former is in use for the time being by
`riverinternaltest` so it can do its existing connection customization
logic, but as we fully migrate it to `rivershared`, we should see if we
can drop that along with `TestTxPool` maybe. Even if we don't drop the
latter, it's not the worst thing to have around because it definitely
increases flexibility.
I also added some code that uses `context.WithoutCancel` to be able to
issue a full rollback in `TestTx` cleanup. This isn't needed by the main
River project yet, but probably will be soon. When switching to the new
Go `t.Context` in tests, the context is cancelled before cleanup phases
are called, so without these changes the rollback will fail.
0 commit comments