mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-28 17:21:03 +00:00
Fix the tests and remaining warnings
This commit is contained in:
committed by
Kerollmops
parent
02c655ff1a
commit
3a4a150ef0
@ -189,23 +189,21 @@ impl<'a> Distinct<'_> for FacetDistinct<'a> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::super::test::{generate_index, validate_distinct_candidates};
|
||||
use super::*;
|
||||
use crate::facet::FacetType;
|
||||
|
||||
macro_rules! test_facet_distinct {
|
||||
($name:ident, $distinct:literal, $facet_type:expr) => {
|
||||
($name:ident, $distinct:literal) => {
|
||||
#[test]
|
||||
fn $name() {
|
||||
use std::iter::FromIterator;
|
||||
|
||||
let facets =
|
||||
HashMap::from_iter(Some(($distinct.to_string(), $facet_type.to_string())));
|
||||
let facets = HashSet::from_iter(Some(($distinct.to_string())));
|
||||
let (index, fid, candidates) = generate_index($distinct, facets);
|
||||
let txn = index.read_txn().unwrap();
|
||||
let mut map_distinct = FacetDistinct::new(fid, &index, &txn, $facet_type);
|
||||
let mut map_distinct = FacetDistinct::new(fid, &index, &txn);
|
||||
let excluded = RoaringBitmap::new();
|
||||
let mut iter = map_distinct.distinct(candidates.clone(), excluded);
|
||||
let count = validate_distinct_candidates(iter.by_ref(), fid, &index);
|
||||
@ -215,7 +213,7 @@ mod test {
|
||||
};
|
||||
}
|
||||
|
||||
test_facet_distinct!(test_string, "txt", FacetType::String);
|
||||
test_facet_distinct!(test_strings, "txts", FacetType::String);
|
||||
test_facet_distinct!(test_number, "cat-int", FacetType::Number);
|
||||
test_facet_distinct!(test_string, "txt");
|
||||
test_facet_distinct!(test_strings, "txts");
|
||||
test_facet_distinct!(test_number, "cat-int");
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ impl<'a, 'b> Distinct<'b> for MapDistinct<'a> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::*;
|
||||
use super::super::test::{generate_index, validate_distinct_candidates};
|
||||
@ -119,7 +119,7 @@ mod test {
|
||||
($name:ident, $distinct:literal) => {
|
||||
#[test]
|
||||
fn $name() {
|
||||
let (index, fid, candidates) = generate_index($distinct, HashMap::new());
|
||||
let (index, fid, candidates) = generate_index($distinct, HashSet::new());
|
||||
let txn = index.read_txn().unwrap();
|
||||
let mut map_distinct = MapDistinct::new(fid, &index, &txn);
|
||||
let excluded = RoaringBitmap::new();
|
||||
|
@ -28,7 +28,7 @@ pub trait Distinct<'a> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashSet;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use rand::{seq::SliceRandom, Rng};
|
||||
@ -74,7 +74,7 @@ mod test {
|
||||
|
||||
/// Returns a temporary index populated with random test documents, the FieldId for the
|
||||
/// distinct attribute, and the RoaringBitmap with the document ids.
|
||||
pub(crate) fn generate_index(distinct: &str, facets: HashMap<String, String>) -> (TempIndex, FieldId, RoaringBitmap) {
|
||||
pub(crate) fn generate_index(distinct: &str, facets: HashSet<String>) -> (TempIndex, FieldId, RoaringBitmap) {
|
||||
let index = TempIndex::new();
|
||||
let mut txn = index.write_txn().unwrap();
|
||||
|
||||
|
Reference in New Issue
Block a user