chore: split tests into multiples files

This commit is contained in:
qdequele 2019-09-18 16:58:51 +02:00
parent 1e2ef06c5c
commit 53ad1fc068
No known key found for this signature in database
GPG Key ID: B3F0A000EBF11745
2 changed files with 58 additions and 0 deletions

View 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()
}

View 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);
}