Skip to content

Commit

Permalink
Add some simple tests for remove_item
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskrause committed Aug 28, 2024
1 parent 9182b11 commit 934ee5e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions core/src/annostorage/inmemory/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,29 @@ fn remove() {
assert_eq!(&0, a.anno_key_sizes.get(&test_anno.key).unwrap_or(&0));
}

#[test]
fn remove_item() {
let test_anno = Annotation {
key: AnnoKey {
name: "anno1".into(),
ns: "annis1".into(),
},
val: "test".into(),
};

let mut a: AnnoStorageImpl<NodeID> = AnnoStorageImpl::new();
a.insert(1, test_anno.clone()).unwrap();

assert_eq!(1, a.number_of_annotations().unwrap());
assert_eq!(1, a.anno_key_sizes.len());
assert_eq!(&1, a.anno_key_sizes.get(&test_anno.key).unwrap());

a.remove_item(&1).unwrap();

assert_eq!(0, a.number_of_annotations().unwrap());
assert_eq!(&0, a.anno_key_sizes.get(&test_anno.key).unwrap_or(&0));
}

#[test]
fn get_node_id_from_name() {
let key = NODE_NAME_KEY.as_ref().clone();
Expand Down
24 changes: 24 additions & 0 deletions core/src/annostorage/ondisk/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,30 @@ fn remove() {
assert_eq!(&0, a.anno_key_sizes.get(&test_anno.key).unwrap_or(&0));
}

#[test]
fn remove_item() {
LOGGER_INIT.call_once(env_logger::init);
let test_anno = Annotation {
key: AnnoKey {
name: "anno1".into(),
ns: "annis1".into(),
},
val: "test".into(),
};

let mut a = AnnoStorageImpl::new(None).unwrap();
a.insert(1, test_anno.clone()).unwrap();

assert_eq!(1, a.number_of_annotations().unwrap());
assert_eq!(1, a.anno_key_sizes.len());
assert_eq!(&1, a.anno_key_sizes.get(&test_anno.key).unwrap());

a.remove_item(&1).unwrap();

assert_eq!(0, a.number_of_annotations().unwrap());
assert_eq!(&0, a.anno_key_sizes.get(&test_anno.key).unwrap_or(&0));
}

#[test]
fn get_node_id_from_name() {
let key = NODE_NAME_KEY.as_ref().clone();
Expand Down

0 comments on commit 934ee5e

Please sign in to comment.