Skip to content

Commit

Permalink
Merge pull request #47 from johanhelsing/initial-notfound-test
Browse files Browse the repository at this point in the history
Test that getting from an empty db returns `NotFound` error
  • Loading branch information
johanhelsing authored Jan 12, 2024
2 parents b5beb2b + ce9fe69 commit ca90659
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ redb = { version = "1.0.1", optional = true }
[dev-dependencies]
bevy = { version = "0.12", default-features = false }
strum_macros = "0.25"
tempfile = "3"

[build-dependencies]
cfg_aliases = "0.1"
Expand Down
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ mod tests {
assert_eq!(ret.unwrap(), "goodbye_custom_path");
}

#[cfg(any(sled_backend, rocksdb_backend, redb_backend))]
#[test]
fn empty_db_not_found() {
use crate::GetError;

setup();

let dir = tempfile::tempdir().expect("failed to create temp dir");
let store = PkvStore::new_in_dir(dir.path());

let err = store.get::<String>("not_there").unwrap_err();

// todo: Use assert_matches! when stable
assert!(matches!(err, GetError::NotFound));
}

#[test]
fn clear() {
setup();
Expand Down

0 comments on commit ca90659

Please sign in to comment.