test: rollback transaction in tests relying on Spanner emulator#2045
test: rollback transaction in tests relying on Spanner emulator#2045
Conversation
f01fec1 to
bb5146f
Compare
pjenvey
left a comment
There was a problem hiding this comment.
In the original issue I had an idea for making a wrapper similar to db_pool.transaction_http/http -- do you think that's feasible?
It would be more explicit than requiring the Drop and requiring the tests to call rollback themselves. One issue with the manual rollback is if any part of the test fails for whatever reason, that rollback won't be called.
It could be a noop on the backends that support test_transactions or it could replace that feature entirely.
I'll take a look.
I misinterpreted your request for making things explicit. |
68707f9 to
c7d47f6
Compare
|
Added |
028653e to
d038c8c
Compare
d038c8c to
a30916c
Compare
syncstorage-db/src/tests/batch.rs
Outdated
|
|
||
| Ok(()) | ||
| with_transaction( | ||
| Some(settings.clone()), |
There was a problem hiding this comment.
nit/not blocking this PR/more of an FYI: there's a Rust idiom where you can avoid the need for Some() here: Into<Option<_>>
syncstorage-db/src/tests/support.rs
Outdated
|
|
||
| /// Wrap a test in a DB transaction that will be rolled back. Read-only tests | ||
| /// do not need this. | ||
| pub async fn with_transaction<T>( |
There was a problem hiding this comment.
Maybe call this test_transaction or with_test_transaction? Especially as it's along similar lines of the use_test_transactions setting which calls diesel's begin_test_transaction.
Which reminds me, diesel even has essentially its own version of this it just calls test_transaction FYI
Co-authored-by: Philip Jenvey <pjenvey@underboss.org>
58a5948 to
026f54e
Compare
We need to explicitly rollback transactions in tests that rely on the Spanner emulator.
Closes STOR-388 / #1850