aboutsummaryrefslogtreecommitdiff
path: root/src/db/test.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-09-21 15:32:25 +0200
committerAlex Auvolat <alex@adnab.me>2023-09-21 15:35:31 +0200
commitf97168f80567f43e15cf236092703e6ae5d8dc2e (patch)
treeca9b06fa1d9bf3af9b33c5db0a8c09a53b403fa9 /src/db/test.rs
parentfd7d8fec59c617b40e480ff855894cf35fdcfb40 (diff)
downloadgarage-f97168f80567f43e15cf236092703e6ae5d8dc2e.tar.gz
garage-f97168f80567f43e15cf236092703e6ae5d8dc2e.zip
garage_db: refactor transactions and add on_commit mechanism
Diffstat (limited to 'src/db/test.rs')
-rw-r--r--src/db/test.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/db/test.rs b/src/db/test.rs
index 40e6c41e..cd99eafa 100644
--- a/src/db/test.rs
+++ b/src/db/test.rs
@@ -13,26 +13,26 @@ fn test_suite(db: Db) {
assert!(tree.insert(ka, va).unwrap().is_none());
assert_eq!(tree.get(ka).unwrap().unwrap(), va);
- let res = db.transaction::<_, (), _>(|mut tx| {
+ let res = db.transaction::<_, (), _>(|tx| {
assert_eq!(tx.get(&tree, ka).unwrap().unwrap(), va);
assert_eq!(tx.insert(&tree, ka, vb).unwrap().unwrap(), va);
assert_eq!(tx.get(&tree, ka).unwrap().unwrap(), vb);
- tx.commit(12)
+ Ok(12)
});
assert!(matches!(res, Ok(12)));
assert_eq!(tree.get(ka).unwrap().unwrap(), vb);
- let res = db.transaction::<(), _, _>(|mut tx| {
+ let res = db.transaction::<(), _, _>(|tx| {
assert_eq!(tx.get(&tree, ka).unwrap().unwrap(), vb);
assert_eq!(tx.insert(&tree, ka, vc).unwrap().unwrap(), vb);
assert_eq!(tx.get(&tree, ka).unwrap().unwrap(), vc);
- tx.abort(42)
+ Err(TxError::Abort(42))
});
assert!(matches!(res, Err(TxError::Abort(42))));
assert_eq!(tree.get(ka).unwrap().unwrap(), vb);