mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-30 00:34:26 +01:00
Remove unused test
This commit is contained in:
parent
da0503ef80
commit
c855cc2721
@ -1955,264 +1955,6 @@ pub(crate) mod tests {
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replace_documents_in_batches_external_ids_and_soft_deletion_check() {
|
||||
use big_s::S;
|
||||
use maplit::hashset;
|
||||
|
||||
let index = TempIndex::new();
|
||||
|
||||
index
|
||||
.update_settings(|settings| {
|
||||
settings.set_primary_key("id".to_owned());
|
||||
settings.set_filterable_fields(hashset! { S("doggo") });
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let add_documents = |index: &TempIndex, docs: Vec<Vec<serde_json::Value>>| {
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut builder = IndexDocuments::new(
|
||||
&mut wtxn,
|
||||
index,
|
||||
&index.indexer_config,
|
||||
index.index_documents_config.clone(),
|
||||
|_| (),
|
||||
|| false,
|
||||
)
|
||||
.unwrap();
|
||||
for docs in docs {
|
||||
(builder, _) = builder.add_documents(documents!(docs)).unwrap();
|
||||
}
|
||||
builder.execute().unwrap();
|
||||
wtxn.commit().unwrap();
|
||||
};
|
||||
// First Batch
|
||||
{
|
||||
let mut docs1 = vec![];
|
||||
for i in 0..4 {
|
||||
docs1.push(serde_json::json!(
|
||||
{ "id": i, "doggo": i }
|
||||
));
|
||||
}
|
||||
add_documents(&index, vec![docs1]);
|
||||
|
||||
db_snap!(index, documents_ids, @"[0, 1, 2, 3, ]");
|
||||
db_snap!(index, external_documents_ids, 1, @r###"
|
||||
docids:
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
"###);
|
||||
db_snap!(index, facet_id_f64_docids, 1, @r###"
|
||||
1 0 0 1 [0, ]
|
||||
1 0 1 1 [1, ]
|
||||
1 0 2 1 [2, ]
|
||||
1 0 3 1 [3, ]
|
||||
"###);
|
||||
}
|
||||
// Second Batch: replace the documents with soft-deletion
|
||||
{
|
||||
let mut docs1 = vec![];
|
||||
for i in 0..3 {
|
||||
docs1.push(serde_json::json!(
|
||||
{ "id": i, "doggo": i+1 }
|
||||
));
|
||||
}
|
||||
let mut docs2 = vec![];
|
||||
for i in 0..3 {
|
||||
docs2.push(serde_json::json!(
|
||||
{ "id": i, "doggo": i }
|
||||
));
|
||||
}
|
||||
add_documents(&index, vec![docs1, docs2]);
|
||||
|
||||
db_snap!(index, documents_ids, @"[0, 1, 2, 3, ]");
|
||||
db_snap!(index, external_documents_ids, 1, @r###"
|
||||
docids:
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
"###);
|
||||
db_snap!(index, facet_id_f64_docids, 1, @r###"
|
||||
1 0 0 1 [0, ]
|
||||
1 0 1 1 [1, ]
|
||||
1 0 2 1 [2, ]
|
||||
1 0 3 1 [3, ]
|
||||
"###);
|
||||
}
|
||||
let rtxn = index.read_txn().unwrap();
|
||||
let (_docid, obkv) = index.documents(&rtxn, [3]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(3),
|
||||
"doggo": Number(3),
|
||||
}
|
||||
"###);
|
||||
let (_docid, obkv) = index.documents(&rtxn, [4]).unwrap()[0];
|
||||
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(0),
|
||||
"doggo": Number(0),
|
||||
}
|
||||
"###);
|
||||
let (_docid, obkv) = index.documents(&rtxn, [5]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(1),
|
||||
"doggo": Number(1),
|
||||
}
|
||||
"###);
|
||||
let (_docid, obkv) = index.documents(&rtxn, [6]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(2),
|
||||
"doggo": Number(2),
|
||||
}
|
||||
"###);
|
||||
drop(rtxn);
|
||||
// Third Batch: replace the documents with soft-deletion again
|
||||
{
|
||||
let mut docs1 = vec![];
|
||||
for i in 0..3 {
|
||||
docs1.push(serde_json::json!(
|
||||
{ "id": i, "doggo": i+1 }
|
||||
));
|
||||
}
|
||||
let mut docs2 = vec![];
|
||||
for i in 0..4 {
|
||||
docs2.push(serde_json::json!(
|
||||
{ "id": i, "doggo": i }
|
||||
));
|
||||
}
|
||||
add_documents(&index, vec![docs1, docs2]);
|
||||
|
||||
db_snap!(index, documents_ids, @"[3, 7, 8, 9, ]");
|
||||
db_snap!(index, external_documents_ids, 1, @r###"
|
||||
soft:
|
||||
hard:
|
||||
0 7
|
||||
1 8
|
||||
2 9
|
||||
3 3
|
||||
"###);
|
||||
db_snap!(index, facet_id_f64_docids, 1, @r###"
|
||||
1 0 0 1 [0, 4, 7, ]
|
||||
1 0 1 1 [1, 5, 8, ]
|
||||
1 0 2 1 [2, 6, 9, ]
|
||||
1 0 3 1 [3, ]
|
||||
"###);
|
||||
}
|
||||
let rtxn = index.read_txn().unwrap();
|
||||
let (_docid, obkv) = index.documents(&rtxn, [3]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(3),
|
||||
"doggo": Number(3),
|
||||
}
|
||||
"###);
|
||||
let (_docid, obkv) = index.documents(&rtxn, [7]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(0),
|
||||
"doggo": Number(0),
|
||||
}
|
||||
"###);
|
||||
let (_docid, obkv) = index.documents(&rtxn, [8]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(1),
|
||||
"doggo": Number(1),
|
||||
}
|
||||
"###);
|
||||
let (_docid, obkv) = index.documents(&rtxn, [9]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(2),
|
||||
"doggo": Number(2),
|
||||
}
|
||||
"###);
|
||||
drop(rtxn);
|
||||
|
||||
// Fourth Batch: replace the documents without soft-deletion
|
||||
{
|
||||
let mut docs1 = vec![];
|
||||
for i in 0..3 {
|
||||
docs1.push(serde_json::json!(
|
||||
{ "id": i, "doggo": i+2 }
|
||||
));
|
||||
}
|
||||
let mut docs2 = vec![];
|
||||
for i in 0..1 {
|
||||
docs2.push(serde_json::json!(
|
||||
{ "id": i, "doggo": i }
|
||||
));
|
||||
}
|
||||
add_documents(&index, vec![docs1, docs2]);
|
||||
|
||||
db_snap!(index, documents_ids, @"[3, 10, 11, 12, ]");
|
||||
db_snap!(index, external_documents_ids, 1, @r###"
|
||||
soft:
|
||||
hard:
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
3 3
|
||||
"###);
|
||||
|
||||
db_snap!(index, facet_id_f64_docids, 1, @r###"
|
||||
1 0 0 1 [10, ]
|
||||
1 0 3 1 [3, 11, ]
|
||||
1 0 4 1 [12, ]
|
||||
"###);
|
||||
|
||||
let rtxn = index.read_txn().unwrap();
|
||||
let (_docid, obkv) = index.documents(&rtxn, [3]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(3),
|
||||
"doggo": Number(3),
|
||||
}
|
||||
"###);
|
||||
let (_docid, obkv) = index.documents(&rtxn, [10]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(0),
|
||||
"doggo": Number(0),
|
||||
}
|
||||
"###);
|
||||
let (_docid, obkv) = index.documents(&rtxn, [11]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(1),
|
||||
"doggo": Number(3),
|
||||
}
|
||||
"###);
|
||||
let (_docid, obkv) = index.documents(&rtxn, [12]).unwrap()[0];
|
||||
let json = obkv_to_json(&[0, 1], &index.fields_ids_map(&rtxn).unwrap(), obkv).unwrap();
|
||||
insta::assert_debug_snapshot!(json, @r###"
|
||||
{
|
||||
"id": Number(2),
|
||||
"doggo": Number(4),
|
||||
}
|
||||
"###);
|
||||
drop(rtxn);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bug_3021_first() {
|
||||
// https://github.com/meilisearch/meilisearch/issues/3021
|
||||
|
Loading…
Reference in New Issue
Block a user