mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
chore: split tests into multiples files
This commit is contained in:
parent
1e2ef06c5c
commit
53ad1fc068
16
meilidb-data/tests/common.rs
Normal file
16
meilidb-data/tests/common.rs
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
use meilidb_data::{Database};
|
||||
use meilidb_data::Index;
|
||||
use meilidb_schema::{SchemaBuilder, DISPLAYED, INDEXED};
|
||||
|
||||
pub fn simple_index() -> Index {
|
||||
let tmp_dir = tempfile::tempdir().unwrap();
|
||||
let database = Database::open(&tmp_dir).unwrap();
|
||||
|
||||
let mut builder = SchemaBuilder::with_identifier("objectId");
|
||||
builder.new_attribute("objectId", DISPLAYED | INDEXED);
|
||||
builder.new_attribute("title", DISPLAYED | INDEXED);
|
||||
let schema = builder.build();
|
||||
|
||||
database.create_index("hello", schema).unwrap()
|
||||
}
|
42
meilidb-data/tests/custom_settings_index.rs
Normal file
42
meilidb-data/tests/custom_settings_index.rs
Normal file
@ -0,0 +1,42 @@
|
||||
mod common;
|
||||
#[macro_use] extern crate maplit;
|
||||
|
||||
use big_s::S;
|
||||
use meilidb_data::{RankingOrdering};
|
||||
|
||||
#[test]
|
||||
fn stop_words() {
|
||||
let index = common::simple_index();
|
||||
let stop_words = hashset!{ S("le"), S("la"), S("les"), };
|
||||
index.custom_settings().set_stop_words(&stop_words).unwrap();
|
||||
let ret_stop_words = index.custom_settings().get_stop_words().unwrap().unwrap();
|
||||
assert_eq!(ret_stop_words, stop_words);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ranking_order() {
|
||||
let index = common::simple_index();
|
||||
let ranking_order = vec![S("SumOfTypos"), S("NumberOfWords"), S("WordsProximity"), S("SumOfWordsAttribute"), S("SumOfWordsPosition"), S("Exact"), S("DocumentId")];
|
||||
index.custom_settings().set_ranking_order(&ranking_order).unwrap();
|
||||
let ret_ranking_orderer = index.custom_settings().get_ranking_order().unwrap().unwrap();
|
||||
assert_eq!(ret_ranking_orderer, ranking_order);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn distinct_field() {
|
||||
let index = common::simple_index();
|
||||
let distinct_field = S("title");
|
||||
index.custom_settings().set_distinct_field(&distinct_field).unwrap();
|
||||
let ret_distinct_field = index.custom_settings().get_distinct_field().unwrap().unwrap();
|
||||
assert_eq!(ret_distinct_field, distinct_field);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ranking_rules() {
|
||||
let index = common::simple_index();
|
||||
let ranking_rules = hashmap!{ S("objectId") => RankingOrdering::Asc };
|
||||
index.custom_settings().set_ranking_rules(&ranking_rules).unwrap();
|
||||
let ret_ranking_rules = index.custom_settings().get_ranking_rules().unwrap().unwrap();
|
||||
assert_eq!(ret_ranking_rules, ranking_rules);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user