mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
Update some tests to reflect changes due to Jayson integration
This commit is contained in:
parent
73845f87cf
commit
c713bd2a9c
@ -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]
|
||||
|
@ -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<Value = Vec<Criterion>> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user