diff --git a/Cargo.toml b/Cargo.toml index d5a44640..d87a49ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/tests/reader.rs b/src/tests/reader.rs index 41162d4d..84adec3a 100644 --- a/src/tests/reader.rs +++ b/src/tests/reader.rs @@ -34,7 +34,7 @@ fn open_unfinished_db() { let rtxn = handle.env.read_txn().unwrap(); let ret = Reader::::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] @@ -50,7 +50,7 @@ fn open_db_with_wrong_dimension() { let rtxn = handle.env.read_txn().unwrap(); let reader = Reader::::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] @@ -89,7 +89,7 @@ fn search_in_db_with_a_single_vector() { let reader = Reader::::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) "###); } @@ -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) @@ -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) @@ -160,7 +160,7 @@ fn two_dimension_on_a_column() { let reader = Reader::::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) @@ -208,14 +208,14 @@ fn filtering() { let reader = Reader::::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) "###); diff --git a/src/tests/writer.rs b/src/tests/writer.rs index 872adc2d..d75e2e9e 100644 --- a/src/tests/writer.rs +++ b/src/tests/writer.rs @@ -46,7 +46,7 @@ fn use_u32_max_minus_one_for_a_vec() { writer.build(&mut wtxn, &mut rng(), Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 4294967294: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 1.0000, 2.0000] }) @@ -65,7 +65,7 @@ fn use_u32_max_for_a_vec() { writer.build(&mut wtxn, &mut rng(), Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 4294967295: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 1.0000, 2.0000] }) @@ -84,7 +84,7 @@ fn write_one_vector() { writer.build(&mut wtxn, &mut rng(), None).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 1.0000, 2.0000] }) @@ -103,7 +103,7 @@ fn write_one_vector_in_one_tree() { writer.build(&mut wtxn, &mut rng(), Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 1.0000, 2.0000] }) @@ -122,7 +122,7 @@ fn write_one_vector_in_multiple_trees() { writer.build(&mut wtxn, &mut rng(), Some(10)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 1.0000, 2.0000] }) @@ -145,7 +145,7 @@ fn write_vectors_until_there_is_a_descendants() { writer.build(&mut wtxn, &mut rng(), Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000, 0.0000] }) @@ -170,7 +170,7 @@ fn write_vectors_until_there_is_a_split() { writer.build(&mut wtxn, &mut rng(), Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000, 0.0000] }) @@ -196,7 +196,7 @@ fn write_and_update_lot_of_random_points() { writer.build(&mut wtxn, &mut rng, Some(10)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle); + insta::assert_snapshot!(handle); let mut wtxn = handle.env.write_txn().unwrap(); let writer = Writer::new(handle.database, 0, 30); @@ -207,7 +207,7 @@ fn write_and_update_lot_of_random_points() { writer.build(&mut wtxn, &mut rng, Some(10)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle); + insta::assert_snapshot!(handle); } #[test] @@ -222,7 +222,7 @@ fn write_multiple_indexes() { } wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 1.0000, 2.0000] }) @@ -286,7 +286,7 @@ fn overwrite_one_item_incremental() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -312,7 +312,7 @@ fn overwrite_one_item_incremental() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -341,7 +341,7 @@ fn delete_one_item_in_a_one_item_db() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -357,7 +357,7 @@ fn delete_one_item_in_a_one_item_db() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Root: Metadata { dimensions: 2, items: RoaringBitmap<[]>, roots: [], distance: "euclidean" } @@ -435,7 +435,7 @@ fn delete_one_item_in_a_descendant() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -452,7 +452,7 @@ fn delete_one_item_in_a_descendant() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 1: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [1.0000, 0.0000] }) @@ -475,7 +475,7 @@ fn delete_one_leaf_in_a_split() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -495,7 +495,7 @@ fn delete_one_leaf_in_a_split() { wtxn.commit().unwrap(); // after deleting the leaf, the split node should be replaced by a descendant - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 1: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [1.0000, 0.0000] }) @@ -517,7 +517,7 @@ fn delete_one_item_in_a_single_document_database() { writer.build(&mut wtxn, &mut rng, None).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderAngular { norm: 0.0 }, vector: [0.0000, 0.0000] }) @@ -533,7 +533,7 @@ fn delete_one_item_in_a_single_document_database() { writer.build(&mut wtxn, &mut rng, None).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Root: Metadata { dimensions: 2, items: RoaringBitmap<[]>, roots: [], distance: "angular" } @@ -554,7 +554,7 @@ fn delete_one_item() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -579,7 +579,7 @@ fn delete_one_item() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -603,7 +603,7 @@ fn delete_one_item() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -626,7 +626,7 @@ fn add_one_item_incrementally_in_an_empty_db() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Root: Metadata { dimensions: 2, items: RoaringBitmap<[]>, roots: [], distance: "euclidean" } @@ -638,7 +638,7 @@ fn add_one_item_incrementally_in_an_empty_db() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -657,7 +657,7 @@ fn add_one_item_incrementally_in_a_one_item_db() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -671,7 +671,7 @@ fn add_one_item_incrementally_in_a_one_item_db() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -692,7 +692,7 @@ fn add_one_item_incrementally_to_create_a_split_node() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -707,7 +707,7 @@ fn add_one_item_incrementally_to_create_a_split_node() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -732,7 +732,7 @@ fn add_one_item_incrementally() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -757,7 +757,7 @@ fn add_one_item_incrementally() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -784,7 +784,7 @@ fn add_one_item_incrementally() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -820,7 +820,7 @@ fn delete_extraneous_tree() { writer.build(&mut wtxn, &mut rng, None).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000, 0.0000, 0.0000] }) @@ -842,7 +842,7 @@ fn delete_extraneous_tree() { writer.build(&mut wtxn, &mut rng, Some(2)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000, 0.0000, 0.0000] }) @@ -862,7 +862,7 @@ fn delete_extraneous_tree() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000, 0.0000, 0.0000] }) @@ -889,7 +889,7 @@ fn reuse_node_id() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -914,7 +914,7 @@ fn reuse_node_id() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -937,7 +937,7 @@ fn reuse_node_id() { writer.build(&mut wtxn, &mut rng, Some(1)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] }) @@ -961,7 +961,7 @@ fn reuse_node_id() { writer.build(&mut wtxn, &mut rng, Some(2)).unwrap(); wtxn.commit().unwrap(); - insta::assert_display_snapshot!(handle, @r###" + insta::assert_snapshot!(handle, @r###" ================== Dumping index 0 Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] })