mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-18 08:48:32 +08:00
add test
This commit is contained in:
parent
8d11b368d1
commit
0cc79d414f
@ -268,3 +268,42 @@ impl Index {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_setting_check() {
|
||||
// test no changes
|
||||
let settings = Settings {
|
||||
displayed_attributes: Some(Some(vec![String::from("hello")])),
|
||||
searchable_attributes: Some(Some(vec![String::from("hello")])),
|
||||
attributes_for_faceting: None,
|
||||
ranking_rules: None,
|
||||
stop_words: None,
|
||||
distinct_attribute: None,
|
||||
_kind: PhantomData::<Unchecked>,
|
||||
};
|
||||
|
||||
let checked = settings.clone().check();
|
||||
assert_eq!(settings.displayed_attributes, checked.displayed_attributes);
|
||||
assert_eq!(settings.searchable_attributes, checked.searchable_attributes);
|
||||
|
||||
// test wildcard
|
||||
// test no changes
|
||||
let settings = Settings {
|
||||
displayed_attributes: Some(Some(vec![String::from("*")])),
|
||||
searchable_attributes: Some(Some(vec![String::from("hello"), String::from("*")])),
|
||||
attributes_for_faceting: None,
|
||||
ranking_rules: None,
|
||||
stop_words: None,
|
||||
distinct_attribute: None,
|
||||
_kind: PhantomData::<Unchecked>,
|
||||
};
|
||||
|
||||
let checked = settings.check();
|
||||
assert_eq!(checked.displayed_attributes, Some(None));
|
||||
assert_eq!(checked.searchable_attributes, Some(None));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user