From 0cc79d414f41d28870fab8543c23a454d18d7ead Mon Sep 17 00:00:00 2001 From: Marin Postma Date: Mon, 10 May 2021 18:34:25 +0200 Subject: [PATCH] add test --- meilisearch-http/src/index/updates.rs | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/meilisearch-http/src/index/updates.rs b/meilisearch-http/src/index/updates.rs index 44d56ac51..0d76f2ae6 100644 --- a/meilisearch-http/src/index/updates.rs +++ b/meilisearch-http/src/index/updates.rs @@ -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::, + }; + + 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::, + }; + + let checked = settings.check(); + assert_eq!(checked.displayed_attributes, Some(None)); + assert_eq!(checked.searchable_attributes, Some(None)); + } +}