mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
Refactor snapshot tests
This commit is contained in:
parent
334098a7e0
commit
ef889ade5d
@ -55,7 +55,6 @@ insta = "1.17.1"
|
|||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
md5 = "0.7.0"
|
md5 = "0.7.0"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
regex = "1.6.0"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
@ -1183,13 +1183,12 @@ pub(crate) mod tests {
|
|||||||
|
|
||||||
use big_s::S;
|
use big_s::S;
|
||||||
use heed::{EnvOpenOptions, RwTxn};
|
use heed::{EnvOpenOptions, RwTxn};
|
||||||
use maplit::btreemap;
|
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
|
||||||
use crate::documents::DocumentsBatchReader;
|
use crate::documents::DocumentsBatchReader;
|
||||||
use crate::index::{DEFAULT_MIN_WORD_LEN_ONE_TYPO, DEFAULT_MIN_WORD_LEN_TWO_TYPOS};
|
use crate::index::{DEFAULT_MIN_WORD_LEN_ONE_TYPO, DEFAULT_MIN_WORD_LEN_TWO_TYPOS};
|
||||||
use crate::update::{self, IndexDocuments, IndexDocumentsConfig, IndexerConfig, Settings};
|
use crate::update::{self, IndexDocuments, IndexDocumentsConfig, IndexerConfig, Settings};
|
||||||
use crate::Index;
|
use crate::{db_snap, Index};
|
||||||
|
|
||||||
pub(crate) struct TempIndex {
|
pub(crate) struct TempIndex {
|
||||||
pub inner: Index,
|
pub inner: Index,
|
||||||
@ -1288,17 +1287,30 @@ pub(crate) mod tests {
|
|||||||
]))
|
]))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let rtxn = index.read_txn().unwrap();
|
db_snap!(index, field_distribution, 1);
|
||||||
let field_distribution = index.field_distribution(&rtxn).unwrap();
|
|
||||||
assert_eq!(
|
db_snap!(index, word_docids,
|
||||||
field_distribution,
|
@r###"
|
||||||
btreemap! {
|
1 [0, ]
|
||||||
"id".to_string() => 2,
|
2 [1, ]
|
||||||
"name".to_string() => 2,
|
20 [1, ]
|
||||||
"age".to_string() => 1,
|
bob [1, ]
|
||||||
}
|
kevin [0, ]
|
||||||
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
db_snap!(index, field_distribution);
|
||||||
|
|
||||||
|
db_snap!(index, field_distribution,
|
||||||
|
@"
|
||||||
|
age 1
|
||||||
|
id 2
|
||||||
|
name 2
|
||||||
|
"
|
||||||
|
);
|
||||||
|
|
||||||
|
// snapshot_index!(&index, "1", include: "^field_distribution$");
|
||||||
|
|
||||||
// we add all the documents a second time. we are supposed to get the same
|
// we add all the documents a second time. we are supposed to get the same
|
||||||
// field_distribution in the end
|
// field_distribution in the end
|
||||||
index
|
index
|
||||||
@ -1309,16 +1321,12 @@ pub(crate) mod tests {
|
|||||||
]))
|
]))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let rtxn = index.read_txn().unwrap();
|
db_snap!(index, field_distribution,
|
||||||
|
@r###"
|
||||||
let field_distribution = index.field_distribution(&rtxn).unwrap();
|
age 1
|
||||||
assert_eq!(
|
id 2
|
||||||
field_distribution,
|
name 2
|
||||||
btreemap! {
|
"###
|
||||||
"id".to_string() => 2,
|
|
||||||
"name".to_string() => 2,
|
|
||||||
"age".to_string() => 1,
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// then we update a document by removing one field and another by adding one field
|
// then we update a document by removing one field and another by adding one field
|
||||||
@ -1329,16 +1337,12 @@ pub(crate) mod tests {
|
|||||||
]))
|
]))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let rtxn = index.read_txn().unwrap();
|
db_snap!(index, field_distribution,
|
||||||
|
@r###"
|
||||||
let field_distribution = index.field_distribution(&rtxn).unwrap();
|
has_dog 1
|
||||||
assert_eq!(
|
id 2
|
||||||
field_distribution,
|
name 2
|
||||||
btreemap! {
|
"###
|
||||||
"id".to_string() => 2,
|
|
||||||
"name".to_string() => 2,
|
|
||||||
"has_dog".to_string() => 1,
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
source: milli/src/index.rs
|
||||||
|
---
|
||||||
|
age 1
|
||||||
|
id 2
|
||||||
|
name 2
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
source: milli/src/index.rs
|
||||||
|
---
|
||||||
|
age 1
|
||||||
|
id 2
|
||||||
|
name 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user