forked from lucid-kv/lucid
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Blocs
committed
Feb 29, 2020
1 parent
81f1ef2
commit c262d2c
Showing
2 changed files
with
69 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use lucid::kvstore::KvStore; | ||
|
||
const CIPHER: std::option::Option<[&str; 2]> = Some([ | ||
"123456789012345678901234123456789012345678901234", | ||
"f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", | ||
]); | ||
|
||
const DATA: [u8; 512] = [42u8; 512]; | ||
|
||
const KEY = String::from("test_value"); | ||
|
||
fn init_kv() -> KvStore { | ||
let kv = KvStore::new(CIPHER); | ||
kv.set(KEY.clone(), DATA.to_vec()); | ||
kv | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn get_returns_a_value() { | ||
let kv = init_kv(); | ||
let value = kv.get(KEY.clone()); | ||
|
||
match value { | ||
Some(v) => assert_eq!(v.data, DATA.to_vec()), | ||
None => panic!("No value found"), | ||
} | ||
} | ||
} |