-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,017 additions
and
609 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
use grovedb::GroveDb; | ||
use tempfile::TempDir; | ||
|
||
#[test] | ||
fn test_some_functionality() { | ||
let primary_dir = TempDir::new().expect("should create temp dir"); | ||
|
||
let primary_grovedb = GroveDb::open(primary_dir.path()).expect("should open grovedb"); | ||
|
||
// Store value in primary | ||
|
||
let key = b"key"; | ||
let value = vec![1, 2, 3]; | ||
|
||
primary_grovedb | ||
.put_aux(key, &value, None, None) | ||
.unwrap() | ||
.expect("should put value to primary"); | ||
|
||
// Read value from primary | ||
|
||
let primary_value = primary_grovedb | ||
.get_aux(key, None) | ||
.unwrap() | ||
.expect("should get value from primary") | ||
.expect("value should exist on primary"); | ||
|
||
assert_eq!(value, primary_value); | ||
|
||
// Open secondary | ||
|
||
let secondary_dir = TempDir::new().expect("should create temp dir"); | ||
|
||
let secondary_grovedb = GroveDb::open_secondary(primary_dir.path(), secondary_dir.path()) | ||
.expect("should open secondary"); | ||
|
||
// Read value on secondary | ||
|
||
let secondary_value = secondary_grovedb | ||
.get_aux(key, None) | ||
.unwrap() | ||
.expect("should get value from secondary") | ||
.expect("value from primary should exist on secondary"); | ||
|
||
assert_eq!(primary_value, secondary_value); | ||
|
||
// Update value on primary | ||
|
||
let primary_value2 = vec![4, 5, 6]; | ||
|
||
primary_grovedb | ||
.put_aux(key, &primary_value2, None, None) | ||
.unwrap() | ||
.expect("should put value to primary"); | ||
|
||
// Catch up secondary | ||
|
||
secondary_grovedb | ||
.try_to_catch_up_from_primary() | ||
.expect("should catch up"); | ||
|
||
// Read updated value on secondary | ||
|
||
let secondary_value2 = secondary_grovedb | ||
.get_aux(key, None) | ||
.unwrap() | ||
.expect("should get value from secondary") | ||
.expect("value from primary should exist on secondary"); | ||
|
||
assert_eq!(primary_value2, secondary_value2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.