Skip to content

Commit

Permalink
update insta and fix the deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
irevoire committed Jun 20, 2024
1 parent 67e74b8 commit 5f63840
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ anyhow = "1.0.75"
arbitrary = { version = "1.3.2", features = ["derive"] }
clap = { version = "4.4.10", features = ["derive"] }
env_logger = "0.10.1"
insta = "1.34.0"
insta = "1.39.0"
instant-distance = "0.6.1"
rand = { version = "0.8.5", features = ["std_rng"] }
tempfile = "3.8.1"
Expand Down
18 changes: 9 additions & 9 deletions src/tests/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn open_unfinished_db() {

let rtxn = handle.env.read_txn().unwrap();
let ret = Reader::<Euclidean>::open(&rtxn, 0, handle.database).map(|_| ()).unwrap_err();
insta::assert_display_snapshot!(ret, @"Metadata are missing on index 0, You must build your database before attempting to read it");
insta::assert_snapshot!(ret, @"Metadata are missing on index 0, You must build your database before attempting to read it");
}

#[test]
Expand All @@ -50,7 +50,7 @@ fn open_db_with_wrong_dimension() {
let rtxn = handle.env.read_txn().unwrap();
let reader = Reader::<Euclidean>::open(&rtxn, 0, handle.database).unwrap();
let ret = reader.nns_by_vector(&rtxn, &[1.0, 2.0, 3.0], 5, None, None).unwrap_err();
insta::assert_display_snapshot!(ret, @"Invalid vector dimensions. Got 3 but expected 2");
insta::assert_snapshot!(ret, @"Invalid vector dimensions. Got 3 but expected 2");
}

#[test]
Expand Down Expand Up @@ -89,7 +89,7 @@ fn search_in_db_with_a_single_vector() {
let reader = Reader::<Angular>::open(&rtxn, 0, handle.database).unwrap();

let ret = reader.nns_by_item(&rtxn, 0, 1, None, None).unwrap();
insta::assert_display_snapshot!(NnsRes(ret), @r###"
insta::assert_snapshot!(NnsRes(ret), @r###"
id(0): distance(0)
"###);
}
Expand All @@ -113,14 +113,14 @@ fn two_dimension_on_a_line() {

// if we can't look into enough nodes we find some random points
let ret = reader.nns_by_item(&rtxn, 0, 5, NonZeroUsize::new(1), None).unwrap();
insta::assert_display_snapshot!(NnsRes(ret), @r###"
insta::assert_snapshot!(NnsRes(ret), @r###"
id(48): distance(48)
id(92): distance(92)
"###);

// if we can look into all the node there is no inifinite loop and it works
let ret = reader.nns_by_item(&rtxn, 0, 5, NonZeroUsize::new(usize::MAX), None).unwrap();
insta::assert_display_snapshot!(NnsRes(ret), @r###"
insta::assert_snapshot!(NnsRes(ret), @r###"
id(0): distance(0)
id(1): distance(1)
id(2): distance(2)
Expand All @@ -129,7 +129,7 @@ fn two_dimension_on_a_line() {
"###);

let ret = reader.nns_by_item(&rtxn, 0, 5, None, None).unwrap();
insta::assert_display_snapshot!(NnsRes(ret), @r###"
insta::assert_snapshot!(NnsRes(ret), @r###"
id(1): distance(1)
id(2): distance(2)
id(3): distance(3)
Expand Down Expand Up @@ -160,7 +160,7 @@ fn two_dimension_on_a_column() {
let reader = Reader::<Euclidean>::open(&rtxn, 0, handle.database).unwrap();
let ret = reader.nns_by_item(&rtxn, 0, 5, None, None).unwrap();

insta::assert_display_snapshot!(NnsRes(ret), @r###"
insta::assert_snapshot!(NnsRes(ret), @r###"
id(1): distance(1)
id(2): distance(2)
id(3): distance(3)
Expand Down Expand Up @@ -208,14 +208,14 @@ fn filtering() {
let reader = Reader::<Euclidean>::open(&rtxn, 0, handle.database).unwrap();

let ret = reader.nns_by_item(&rtxn, 0, 5, None, Some(&RoaringBitmap::from_iter(0..2))).unwrap();
insta::assert_display_snapshot!(NnsRes(ret), @r###"
insta::assert_snapshot!(NnsRes(ret), @r###"
id(0): distance(0)
id(1): distance(1)
"###);

let ret =
reader.nns_by_item(&rtxn, 0, 5, None, Some(&RoaringBitmap::from_iter(98..1000))).unwrap();
insta::assert_display_snapshot!(NnsRes(ret), @r###"
insta::assert_snapshot!(NnsRes(ret), @r###"
id(98): distance(98)
id(99): distance(99)
"###);
Expand Down
Loading

0 comments on commit 5f63840

Please sign in to comment.