mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Fix the tests
This commit is contained in:
parent
0d4482625a
commit
462b4c0080
6 changed files with 33 additions and 60 deletions
|
@ -1594,7 +1594,7 @@ pub(crate) mod tests {
|
|||
}
|
||||
pub fn add_documents_using_wtxn<'t, R>(
|
||||
&'t self,
|
||||
wtxn: &mut RwTxn<'t, '_>,
|
||||
wtxn: &mut RwTxn<'t>,
|
||||
documents: DocumentsBatchReader<R>,
|
||||
) -> Result<(), crate::error::Error>
|
||||
where
|
||||
|
@ -1638,7 +1638,7 @@ pub(crate) mod tests {
|
|||
}
|
||||
pub fn update_settings_using_wtxn<'t>(
|
||||
&'t self,
|
||||
wtxn: &mut RwTxn<'t, '_>,
|
||||
wtxn: &mut RwTxn<'t>,
|
||||
update: impl Fn(&mut Settings),
|
||||
) -> Result<(), crate::error::Error> {
|
||||
let mut builder = update::Settings::new(wtxn, &self.inner, &self.indexer_config);
|
||||
|
@ -1649,7 +1649,7 @@ pub(crate) mod tests {
|
|||
|
||||
pub fn delete_documents_using_wtxn<'t>(
|
||||
&'t self,
|
||||
wtxn: &mut RwTxn<'t, '_>,
|
||||
wtxn: &mut RwTxn<'t>,
|
||||
external_document_ids: Vec<String>,
|
||||
) {
|
||||
let builder = IndexDocuments::new(
|
||||
|
|
|
@ -486,8 +486,8 @@ pub(crate) mod test_helpers {
|
|||
|
||||
let iter = self
|
||||
.content
|
||||
.as_polymorph()
|
||||
.prefix_iter::<_, ByteSlice, FacetGroupValueCodec>(txn, &level_no_prefix)
|
||||
.remap_types::<ByteSlice, FacetGroupValueCodec>()
|
||||
.prefix_iter(txn, &level_no_prefix)
|
||||
.unwrap();
|
||||
for el in iter {
|
||||
let (key, value) = el.unwrap();
|
||||
|
@ -501,11 +501,8 @@ pub(crate) mod test_helpers {
|
|||
let start_below = {
|
||||
let mut start_below_iter = self
|
||||
.content
|
||||
.as_polymorph()
|
||||
.prefix_iter::<_, ByteSlice, FacetGroupValueCodec>(
|
||||
txn,
|
||||
&prefix_start_below,
|
||||
)
|
||||
.remap_types::<ByteSlice, FacetGroupValueCodec>()
|
||||
.prefix_iter(txn, &prefix_start_below)
|
||||
.unwrap();
|
||||
let (key_bytes, _) = start_below_iter.next().unwrap().unwrap();
|
||||
FacetGroupKeyCodec::<ByteSliceRefCodec>::bytes_decode(key_bytes).unwrap()
|
||||
|
@ -612,7 +609,7 @@ mod comparison_bench {
|
|||
}
|
||||
let time_spent = timer.elapsed().as_millis();
|
||||
println!(" add {nbr_doc} : {time_spent}ms");
|
||||
txn.abort().unwrap();
|
||||
txn.abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -701,7 +701,7 @@ mod tests {
|
|||
use crate::documents::documents_batch_reader_from_objects;
|
||||
use crate::index::tests::TempIndex;
|
||||
use crate::search::TermsMatchingStrategy;
|
||||
use crate::{db_snap, Filter, Search, BEU16};
|
||||
use crate::{db_snap, Filter, Search};
|
||||
|
||||
#[test]
|
||||
fn simple_document_replacement() {
|
||||
|
@ -1743,14 +1743,11 @@ mod tests {
|
|||
let colour_green_id = index.fields_ids_map(&rtxn).unwrap().id("colour.green").unwrap();
|
||||
|
||||
let bitmap_colour =
|
||||
index.facet_id_exists_docids.get(&rtxn, &BEU16::new(colour_id)).unwrap().unwrap();
|
||||
index.facet_id_exists_docids.get(&rtxn, &colour_id).unwrap().unwrap();
|
||||
assert_eq!(bitmap_colour.into_iter().collect::<Vec<_>>(), vec![0, 1, 2, 3, 4, 6, 7]);
|
||||
|
||||
let bitmap_colour_green = index
|
||||
.facet_id_exists_docids
|
||||
.get(&rtxn, &BEU16::new(colour_green_id))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let bitmap_colour_green =
|
||||
index.facet_id_exists_docids.get(&rtxn, &colour_green_id).unwrap().unwrap();
|
||||
assert_eq!(bitmap_colour_green.into_iter().collect::<Vec<_>>(), vec![6, 7]);
|
||||
};
|
||||
|
||||
|
@ -1848,21 +1845,15 @@ mod tests {
|
|||
index.fields_ids_map(&rtxn).unwrap().id("colour.green.blue").unwrap();
|
||||
|
||||
let bitmap_null_colour =
|
||||
index.facet_id_is_null_docids.get(&rtxn, &BEU16::new(colour_id)).unwrap().unwrap();
|
||||
index.facet_id_is_null_docids.get(&rtxn, &colour_id).unwrap().unwrap();
|
||||
assert_eq!(bitmap_null_colour.into_iter().collect::<Vec<_>>(), vec![0]);
|
||||
|
||||
let bitmap_colour_green = index
|
||||
.facet_id_is_null_docids
|
||||
.get(&rtxn, &BEU16::new(colour_green_id))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let bitmap_colour_green =
|
||||
index.facet_id_is_null_docids.get(&rtxn, &colour_green_id).unwrap().unwrap();
|
||||
assert_eq!(bitmap_colour_green.into_iter().collect::<Vec<_>>(), vec![2]);
|
||||
|
||||
let bitmap_colour_blue = index
|
||||
.facet_id_is_null_docids
|
||||
.get(&rtxn, &BEU16::new(colour_blue_id))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let bitmap_colour_blue =
|
||||
index.facet_id_is_null_docids.get(&rtxn, &colour_blue_id).unwrap().unwrap();
|
||||
assert_eq!(bitmap_colour_blue.into_iter().collect::<Vec<_>>(), vec![3]);
|
||||
};
|
||||
|
||||
|
@ -1917,21 +1908,15 @@ mod tests {
|
|||
let tags_blue_id = index.fields_ids_map(&rtxn).unwrap().id("tags.green.blue").unwrap();
|
||||
|
||||
let bitmap_empty_tags =
|
||||
index.facet_id_is_empty_docids.get(&rtxn, &BEU16::new(tags_id)).unwrap().unwrap();
|
||||
index.facet_id_is_empty_docids.get(&rtxn, &tags_id).unwrap().unwrap();
|
||||
assert_eq!(bitmap_empty_tags.into_iter().collect::<Vec<_>>(), vec![2, 6, 9]);
|
||||
|
||||
let bitmap_tags_green = index
|
||||
.facet_id_is_empty_docids
|
||||
.get(&rtxn, &BEU16::new(tags_green_id))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let bitmap_tags_green =
|
||||
index.facet_id_is_empty_docids.get(&rtxn, &tags_green_id).unwrap().unwrap();
|
||||
assert_eq!(bitmap_tags_green.into_iter().collect::<Vec<_>>(), vec![8]);
|
||||
|
||||
let bitmap_tags_blue = index
|
||||
.facet_id_is_empty_docids
|
||||
.get(&rtxn, &BEU16::new(tags_blue_id))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let bitmap_tags_blue =
|
||||
index.facet_id_is_empty_docids.get(&rtxn, &tags_blue_id).unwrap().unwrap();
|
||||
assert_eq!(bitmap_tags_blue.into_iter().collect::<Vec<_>>(), vec![12]);
|
||||
};
|
||||
|
||||
|
@ -2684,7 +2669,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn delete_documents<'t>(
|
||||
wtxn: &mut RwTxn<'t, '_>,
|
||||
wtxn: &mut RwTxn<'t>,
|
||||
index: &'t TempIndex,
|
||||
external_ids: &[&str],
|
||||
) -> Vec<u32> {
|
||||
|
|
|
@ -1565,7 +1565,7 @@ mod tests {
|
|||
})
|
||||
.unwrap_err();
|
||||
assert!(matches!(error, Error::UserError(UserError::PrimaryKeyCannotBeChanged(_))));
|
||||
wtxn.abort().unwrap();
|
||||
wtxn.abort();
|
||||
|
||||
// But if we clear the database...
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue