Adds some tests related to transactions

pull/46/head
Tpt 4 years ago
parent fdc0dbbeef
commit 13b8518eda
  1. 8
      lib/src/store/rocksdb.rs
  2. 10
      lib/src/store/sled.rs

@ -1231,10 +1231,16 @@ fn store() -> Result<(), io::Error> {
{ {
let store = RocksDbStore::open(&repo_path)?; let store = RocksDbStore::open(&repo_path)?;
for t in &all_quads { for t in &default_quads {
store.insert(t)?; store.insert(t)?;
} }
store.transaction(|t| {
t.remove(&default_quad)?;
t.insert(&named_quad)?;
t.insert(&default_quad)
})?;
assert_eq!(store.len(), 4); assert_eq!(store.len(), 4);
assert_eq!( assert_eq!(
store store

@ -1280,10 +1280,18 @@ fn store() -> Result<(), io::Error> {
]; ];
let store = SledStore::new()?; let store = SledStore::new()?;
for t in &all_quads { for t in &default_quads {
store.insert(t)?; store.insert(t)?;
} }
let result: Result<_, SledTransactionError<io::Error>> = store.transaction(|t| {
t.remove(&default_quad)?;
t.insert(&named_quad)?;
t.insert(&default_quad)?;
Ok(())
});
result?;
assert_eq!(store.len(), 4); assert_eq!(store.len(), 4);
assert_eq!( assert_eq!(
store store

Loading…
Cancel
Save