diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-03 15:31:07 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-03 15:31:07 +0200 |
commit | 4e72c713f157ae9d5103a461c4c213b2aa6a84b9 (patch) | |
tree | 50fca54ff6540490846d0aa65be5a3c7bfde0e17 /src/db/test.rs | |
parent | 16e0a655d0d01e3871aee81a0a9660102d6df74e (diff) | |
download | garage-4e72c713f157ae9d5103a461c4c213b2aa6a84b9.tar.gz garage-4e72c713f157ae9d5103a461c4c213b2aa6a84b9.zip |
Start LMDB adapter, with fixed semantics
Diffstat (limited to 'src/db/test.rs')
-rw-r--r-- | src/db/test.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/db/test.rs b/src/db/test.rs index 75200cf1..e5b83ab5 100644 --- a/src/db/test.rs +++ b/src/db/test.rs @@ -1,5 +1,6 @@ use crate::*; +use crate::lmdb_adapter::LmdbDb; use crate::sled_adapter::SledDb; use crate::sqlite_adapter::SqliteDb; @@ -16,7 +17,7 @@ fn test_suite(db: Db) { tree.insert(ka, va).unwrap(); assert_eq!(tree.get(ka).unwrap().unwrap(), va); - let res = db.transaction::<_, (), _>(|tx| { + let res = db.transaction::<_, (), _>(|mut tx| { assert_eq!(tx.get(&tree, ka).unwrap().unwrap(), va); tx.insert(&tree, ka, vb).unwrap(); @@ -28,7 +29,7 @@ fn test_suite(db: Db) { assert!(matches!(res, Ok(12))); assert_eq!(tree.get(ka).unwrap().unwrap(), vb); - let res = db.transaction::<(), _, _>(|tx| { + let res = db.transaction::<(), _, _>(|mut tx| { assert_eq!(tx.get(&tree, ka).unwrap().unwrap(), vb); tx.insert(&tree, ka, vc).unwrap(); @@ -79,6 +80,18 @@ fn test_suite(db: Db) { } #[test] +fn test_lmdb_db() { + let path = mktemp::Temp::new_dir().unwrap(); + let db = lmdb::Environment::new() + .set_max_dbs(100) + .open(&path) + .unwrap(); + let db = LmdbDb::init(db); + test_suite(db); + drop(path); +} + +#[test] fn test_sled_db() { let path = mktemp::Temp::new_dir().unwrap(); let db = SledDb::init(sled::open(path.to_path_buf()).unwrap()); |