diff --git a/meilisearch-http/tests/settings/get_settings.rs b/meilisearch-http/tests/settings/get_settings.rs index 0862b15c5..6ac169b70 100644 --- a/meilisearch-http/tests/settings/get_settings.rs +++ b/meilisearch-http/tests/settings/get_settings.rs @@ -291,23 +291,20 @@ async fn error_set_invalid_ranking_rules() { let index = server.index("test"); index.create(None).await; - let (_response, _code) = index + let (response, code) = index .update_settings(json!({ "rankingRules": [ "manyTheFish"]})) .await; - index.wait_task(1).await; - let (response, code) = index.get_task(1).await; - assert_eq!(code, 200); - assert_eq!(response["status"], "failed"); + assert_eq!(code, 400); let expected_error = json!({ - "message": r#"`manyTheFish` ranking rule is invalid. Valid ranking rules are words, typo, sort, proximity, attribute, exactness and custom ranking rules."#, - "code": "invalid_ranking_rule", - "type": "invalid_request", - "link": "https://docs.meilisearch.com/errors#invalid_ranking_rule" + "code": "malformed_payload", + "link": "https://docs.meilisearch.com/errors#malformed_payload", + "message": "ValuePointer { path: [Key(\"rankingRules\"), Index(0)] } -> `manyTheFish` ranking rule is invalid. Valid ranking rules are words, typo, sort, proximity, attribute, exactness and custom ranking rules. ", + "type": "invalid_request" }); - assert_eq!(response["error"], expected_error); + assert_eq!(response, expected_error); } #[actix_rt::test] diff --git a/meilisearch-lib/src/index/updates.rs b/meilisearch-lib/src/index/updates.rs index 1636f6a6d..ff5fc9821 100644 --- a/meilisearch-lib/src/index/updates.rs +++ b/meilisearch-lib/src/index/updates.rs @@ -423,8 +423,10 @@ pub fn apply_settings_to_builder(settings: &Settings, builder: &mut milli::updat #[cfg(test)] pub(crate) mod test { use super::*; + use meilisearch_types::error::MeiliDeserError; use milli::Criterion; use proptest::prelude::*; + use serde_json::json; fn criteria_strategy() -> impl Strategy> { proptest::collection::vec( @@ -459,44 +461,21 @@ pub(crate) mod test { #[test] fn test_setting_check() { - // test no changes - let settings = Settings { - displayed_attributes: Setting::Set(vec![String::from("hello")]), - searchable_attributes: Setting::Set(vec![String::from("hello")]), - filterable_attributes: Setting::NotSet, - sortable_attributes: Setting::NotSet, - ranking_rules: Setting::NotSet, - stop_words: Setting::NotSet, - synonyms: Setting::NotSet, - distinct_attribute: Setting::NotSet, - typo_tolerance: Setting::NotSet, - faceting: Setting::NotSet, - pagination: Setting::NotSet, - }; - - assert_eq!(settings.displayed_attributes, settings.displayed_attributes); + let j = json!({ + "filterableAttributes": ["a", "b"], + "searchableAttributes": ["*", "b"], + }); + let settings: Settings = jayson::deserialize::<_, _, MeiliDeserError>(j).unwrap(); assert_eq!( - settings.searchable_attributes, - settings.searchable_attributes + settings.filterable_attributes, + Setting::Set([String::from("a"), String::from("b")].into_iter().collect()) ); - - // test wildcard - // test no changes - let settings = Settings { - displayed_attributes: Setting::Set(vec![String::from("*")]), - searchable_attributes: Setting::Set(vec![String::from("hello"), String::from("*")]), - filterable_attributes: Setting::NotSet, - sortable_attributes: Setting::NotSet, - ranking_rules: Setting::NotSet, - stop_words: Setting::NotSet, - synonyms: Setting::NotSet, - distinct_attribute: Setting::NotSet, - typo_tolerance: Setting::NotSet, - faceting: Setting::NotSet, - pagination: Setting::NotSet, - }; - - assert_eq!(settings.displayed_attributes, Setting::Reset); assert_eq!(settings.searchable_attributes, Setting::Reset); + + let j = json!({ + "displayedAttributes": ["c", "*"], + }); + let settings: Settings = jayson::deserialize::<_, _, MeiliDeserError>(j).unwrap(); + assert_eq!(settings.displayed_attributes, Setting::Reset); } }