More tests pass

This commit is contained in:
Louis Dureuil 2024-11-20 11:13:36 +01:00 committed by Clément Renault
parent f893b5153e
commit 61feca1f41
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -2902,17 +2902,14 @@ mod tests {
fn placeholder_search_should_not_return_deleted_documents() {
let index = TempIndex::new();
let mut wtxn = index.write_txn().unwrap();
index
.update_settings_using_wtxn(&mut wtxn, |settings| {
.update_settings(|settings| {
settings.set_primary_key(S("docid"));
})
.unwrap();
index
.add_documents_using_wtxn(
&mut wtxn,
documents!([
.add_documents(documents!([
{ "docid": "1_4", "label": ["sign"] },
{ "docid": "1_5", "label": ["letter"] },
{ "docid": "1_7", "label": ["abstract","cartoon","design","pattern"] },
@ -2936,14 +2933,19 @@ mod tests {
{ "docid": "1_70", "label2": ["geometry", 1.2] },
{ "docid": "1_71", "label2": ["design", 2.2] },
{ "docid": "1_72", "label2": ["geometry", 1.2] }
]),
)
]))
.unwrap();
let mut wtxn = index.write_txn().unwrap();
let deleted_internal_ids = delete_documents(&mut wtxn, &index, &["1_4"]);
wtxn.commit().unwrap();
// Placeholder search
let results = index.search(&wtxn).execute().unwrap();
let rtxn = index.static_read_txn().unwrap();
let results = index.search(&rtxn).execute().unwrap();
assert!(!results.documents_ids.is_empty());
for id in results.documents_ids.iter() {
assert!(
@ -2953,24 +2955,21 @@ mod tests {
);
}
wtxn.commit().unwrap();
drop(rtxn);
}
#[test]
fn search_should_not_return_deleted_documents() {
let index = TempIndex::new();
let mut wtxn = index.write_txn().unwrap();
index
.update_settings_using_wtxn(&mut wtxn, |settings| {
.update_settings(|settings| {
settings.set_primary_key(S("docid"));
})
.unwrap();
index
.add_documents_using_wtxn(
&mut wtxn,
documents!([
.add_documents(documents!([
{ "docid": "1_4", "label": ["sign"] },
{ "docid": "1_5", "label": ["letter"] },
{ "docid": "1_7", "label": ["abstract","cartoon","design","pattern"] },
@ -2994,14 +2993,16 @@ mod tests {
{ "docid": "1_70", "label2": ["geometry", 1.2] },
{ "docid": "1_71", "label2": ["design", 2.2] },
{ "docid": "1_72", "label2": ["geometry", 1.2] }
]),
)
]))
.unwrap();
let mut wtxn = index.write_txn().unwrap();
let deleted_internal_ids = delete_documents(&mut wtxn, &index, &["1_7", "1_52"]);
wtxn.commit().unwrap();
// search for abstract
let results = index.search(&wtxn).query("abstract").execute().unwrap();
let rtxn = index.read_txn().unwrap();
let results = index.search(&rtxn).query("abstract").execute().unwrap();
assert!(!results.documents_ids.is_empty());
for id in results.documents_ids.iter() {
assert!(
@ -3010,8 +3011,6 @@ mod tests {
id
);
}
wtxn.commit().unwrap();
}
#[test]