Skip to content

Commit

Permalink
Add test for InMemoryBackend
Browse files Browse the repository at this point in the history
  • Loading branch information
cberner committed Oct 23, 2023
1 parent 8cf6cc8 commit dc0b54f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/basic_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use redb::backends::InMemoryBackend;
use redb::{
Database, MultimapTableDefinition, MultimapTableHandle, Range, ReadableTable, RedbKey,
RedbValue, TableDefinition, TableHandle, TypeName,
Expand Down Expand Up @@ -36,6 +37,25 @@ fn len() {
assert_eq!(table.len().unwrap(), 3);
}

#[test]
fn in_memory() {
let db = Database::builder()
.create_with_backend(InMemoryBackend::new())
.unwrap();
let write_txn = db.begin_write().unwrap();
{
let mut table = write_txn.open_table(STR_TABLE).unwrap();
table.insert("hello", "world").unwrap();
table.insert("hello2", "world2").unwrap();
table.insert("hi", "world").unwrap();
}
write_txn.commit().unwrap();

let read_txn = db.begin_read().unwrap();
let table = read_txn.open_table(STR_TABLE).unwrap();
assert_eq!(table.len().unwrap(), 3);
}

#[test]
fn first_last() {
let tmpfile = create_tempfile();
Expand Down

0 comments on commit dc0b54f

Please sign in to comment.