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");
|
let index = server.index("test");
|
||||||
index.create(None).await;
|
index.create(None).await;
|
||||||
|
|
||||||
let (_response, _code) = index
|
let (response, code) = index
|
||||||
.update_settings(json!({ "rankingRules": [ "manyTheFish"]}))
|
.update_settings(json!({ "rankingRules": [ "manyTheFish"]}))
|
||||||
.await;
|
.await;
|
||||||
index.wait_task(1).await;
|
|
||||||
let (response, code) = index.get_task(1).await;
|
|
||||||
|
|
||||||
assert_eq!(code, 200);
|
assert_eq!(code, 400);
|
||||||
assert_eq!(response["status"], "failed");
|
|
||||||
|
|
||||||
let expected_error = json!({
|
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": "malformed_payload",
|
||||||
"code": "invalid_ranking_rule",
|
"link": "https://docs.meilisearch.com/errors#malformed_payload",
|
||||||
"type": "invalid_request",
|
"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. ",
|
||||||
"link": "https://docs.meilisearch.com/errors#invalid_ranking_rule"
|
"type": "invalid_request"
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_eq!(response["error"], expected_error);
|
assert_eq!(response, expected_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
@ -423,8 +423,10 @@ pub fn apply_settings_to_builder(settings: &Settings, builder: &mut milli::updat
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(crate) mod test {
|
pub(crate) mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use meilisearch_types::error::MeiliDeserError;
|
||||||
use milli::Criterion;
|
use milli::Criterion;
|
||||||
use proptest::prelude::*;
|
use proptest::prelude::*;
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
fn criteria_strategy() -> impl Strategy<Value = Vec<Criterion>> {
|
fn criteria_strategy() -> impl Strategy<Value = Vec<Criterion>> {
|
||||||
proptest::collection::vec(
|
proptest::collection::vec(
|
||||||
@ -459,44 +461,21 @@ pub(crate) mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_setting_check() {
|
fn test_setting_check() {
|
||||||
// test no changes
|
let j = json!({
|
||||||
let settings = Settings {
|
"filterableAttributes": ["a", "b"],
|
||||||
displayed_attributes: Setting::Set(vec![String::from("hello")]),
|
"searchableAttributes": ["*", "b"],
|
||||||
searchable_attributes: Setting::Set(vec![String::from("hello")]),
|
});
|
||||||
filterable_attributes: Setting::NotSet,
|
let settings: Settings = jayson::deserialize::<_, _, MeiliDeserError>(j).unwrap();
|
||||||
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);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
settings.searchable_attributes,
|
settings.filterable_attributes,
|
||||||
settings.searchable_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);
|
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