Update test

This commit is contained in:
ManyTheFish 2023-02-01 15:34:01 +01:00
parent 77d32d0ee8
commit 064158e4e2
3 changed files with 26 additions and 9 deletions

View File

@ -23,4 +23,3 @@ pub use self::roaring_bitmap_length::{
pub use self::script_language_codec::ScriptLanguageCodec;
pub use self::str_beu32_codec::StrBEU32Codec;
pub use self::str_str_u8_codec::{U8StrStrCodec, UncheckedU8StrStrCodec};
pub use self::script_language_codec::ScriptLanguageCodec;

View File

@ -19,8 +19,7 @@ use crate::heed_codec::facet::{
FacetGroupKeyCodec, FacetGroupValueCodec, FieldDocIdFacetF64Codec, FieldDocIdFacetStringCodec,
FieldIdCodec, OrderedF64Codec,
};
use crate::heed_codec::StrRefCodec;
use crate::heed_codec::ScriptLanguageCodec;
use crate::heed_codec::{ScriptLanguageCodec, StrRefCodec};
use crate::{
default_criteria, BEU32StrCodec, BoRoaringBitmapCodec, CboRoaringBitmapCodec, Criterion,
DocumentId, ExternalDocumentsIds, FacetDistribution, FieldDistribution, FieldId,
@ -154,7 +153,7 @@ impl Index {
) -> Result<Index> {
use db_name::*;
options.max_dbs(18);
options.max_dbs(19);
unsafe { options.flag(Flags::MdbAlwaysFreePages) };
let env = options.open(path)?;

View File

@ -1184,8 +1184,9 @@ mod tests {
stats_should_not_return_deleted_documents_(DeletionStrategy::AlwaysSoft);
}
#[test]
fn stored_detected_script_and_language_should_not_return_deleted_documents() {
fn stored_detected_script_and_language_should_not_return_deleted_documents_(
deletion_strategy: DeletionStrategy,
) {
use charabia::{Language, Script};
let index = TempIndex::new();
let mut wtxn = index.write_txn().unwrap();
@ -1202,14 +1203,32 @@ mod tests {
]))
.unwrap();
delete_documents(&mut wtxn, &index, &["1"]);
let key_cmn = (Script::Cj, Language::Cmn);
let cj_cmn_docs =
index.script_language_documents_ids(&wtxn, &key_cmn).unwrap().unwrap_or_default();
let mut expected_cj_cmn_docids = RoaringBitmap::new();
expected_cj_cmn_docids.push(1);
expected_cj_cmn_docids.push(5);
assert_eq!(cj_cmn_docs, expected_cj_cmn_docids);
delete_documents(&mut wtxn, &index, &["1"], deletion_strategy);
wtxn.commit().unwrap();
let rtxn = index.read_txn().unwrap();
let key_cmn = (Script::Cj, Language::Cmn);
let cj_cmn_docs = index.script_language_documents_ids(&rtxn, &key_cmn).unwrap().unwrap();
let cj_cmn_docs =
index.script_language_documents_ids(&rtxn, &key_cmn).unwrap().unwrap_or_default();
let mut expected_cj_cmn_docids = RoaringBitmap::new();
expected_cj_cmn_docids.push(5);
assert_eq!(cj_cmn_docs, expected_cj_cmn_docids);
}
#[test]
fn stored_detected_script_and_language_should_not_return_deleted_documents() {
stored_detected_script_and_language_should_not_return_deleted_documents_(
DeletionStrategy::AlwaysHard,
);
stored_detected_script_and_language_should_not_return_deleted_documents_(
DeletionStrategy::AlwaysSoft,
);
}
}