mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 12:05:05 +08:00
add tests on the sub settings routes
This commit is contained in:
parent
b0b7ad7caf
commit
b252c87197
@ -197,6 +197,76 @@ impl Index<'_> {
|
|||||||
self.service.patch_encoded(url, settings, self.encoder).await
|
self.service.patch_encoded(url, settings, self.encoder).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_displayed_attributes(
|
||||||
|
&self,
|
||||||
|
settings: Value,
|
||||||
|
) -> (Value, StatusCode) {
|
||||||
|
let url =
|
||||||
|
format!("/indexes/{}/settings/displayed-attributes", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.put_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_searchable_attributes(
|
||||||
|
&self,
|
||||||
|
settings: Value,
|
||||||
|
) -> (Value, StatusCode) {
|
||||||
|
let url =
|
||||||
|
format!("/indexes/{}/settings/searchable-attributes", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.put_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_filterable_attributes(
|
||||||
|
&self,
|
||||||
|
settings: Value,
|
||||||
|
) -> (Value, StatusCode) {
|
||||||
|
let url =
|
||||||
|
format!("/indexes/{}/settings/filterable-attributes", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.put_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_sortable_attributes(
|
||||||
|
&self,
|
||||||
|
settings: Value,
|
||||||
|
) -> (Value, StatusCode) {
|
||||||
|
let url = format!("/indexes/{}/settings/sortable-attributes", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.put_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_ranking_rules(&self, settings: Value) -> (Value, StatusCode) {
|
||||||
|
let url = format!("/indexes/{}/settings/ranking-rules", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.put_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_stop_words(&self, settings: Value) -> (Value, StatusCode) {
|
||||||
|
let url = format!("/indexes/{}/settings/stop-words", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.put_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_synonyms(&self, settings: Value) -> (Value, StatusCode) {
|
||||||
|
let url = format!("/indexes/{}/settings/synonyms", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.put_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_distinct_attribute(&self, settings: Value) -> (Value, StatusCode) {
|
||||||
|
let url = format!("/indexes/{}/settings/distinct-attribute", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.put_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_typo_tolerance(&self, settings: Value) -> (Value, StatusCode) {
|
||||||
|
let url = format!("/indexes/{}/settings/typo-tolerance", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.patch_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_faceting(&self, settings: Value) -> (Value, StatusCode) {
|
||||||
|
let url = format!("/indexes/{}/settings/faceting", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.patch_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_settings_pagination(&self, settings: Value) -> (Value, StatusCode) {
|
||||||
|
let url = format!("/indexes/{}/settings/pagination", urlencode(self.uid.as_ref()));
|
||||||
|
self.service.patch_encoded(url, settings, self.encoder).await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn delete_settings(&self) -> (Value, StatusCode) {
|
pub async fn delete_settings(&self) -> (Value, StatusCode) {
|
||||||
let url = format!("/indexes/{}/settings", urlencode(self.uid.as_ref()));
|
let url = format!("/indexes/{}/settings", urlencode(self.uid.as_ref()));
|
||||||
self.service.delete(url).await
|
self.service.delete(url).await
|
||||||
|
@ -18,6 +18,17 @@ async fn settings_bad_displayed_attributes() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-displayed-attributes"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-displayed-attributes"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_displayed_attributes(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Sequence at ``.",
|
||||||
|
"code": "invalid_settings_displayed_attributes",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-displayed-attributes"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -35,6 +46,17 @@ async fn settings_bad_searchable_attributes() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-searchable-attributes"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-searchable-attributes"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_searchable_attributes(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Sequence at ``.",
|
||||||
|
"code": "invalid_settings_searchable_attributes",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-searchable-attributes"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -52,6 +74,17 @@ async fn settings_bad_filterable_attributes() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-filterable-attributes"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-filterable-attributes"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_filterable_attributes(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Sequence at ``.",
|
||||||
|
"code": "invalid_settings_filterable_attributes",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-filterable-attributes"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -69,6 +102,17 @@ async fn settings_bad_sortable_attributes() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-sortable-attributes"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-sortable-attributes"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_sortable_attributes(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Sequence at ``.",
|
||||||
|
"code": "invalid_settings_sortable_attributes",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-sortable-attributes"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -86,6 +130,17 @@ async fn settings_bad_ranking_rules() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-ranking-rules"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-ranking-rules"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_ranking_rules(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Sequence at ``.",
|
||||||
|
"code": "invalid_settings_ranking_rules",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-ranking-rules"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -103,6 +158,17 @@ async fn settings_bad_stop_words() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-stop-words"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-stop-words"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_stop_words(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Sequence at ``.",
|
||||||
|
"code": "invalid_settings_stop_words",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-stop-words"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -120,6 +186,17 @@ async fn settings_bad_synonyms() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-synonyms"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-synonyms"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_synonyms(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Map at ``.",
|
||||||
|
"code": "invalid_settings_synonyms",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-synonyms"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -137,6 +214,17 @@ async fn settings_bad_distinct_attribute() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-distinct-attribute"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-distinct-attribute"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_distinct_attribute(json!(["doggo"])).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: Sequence `[\"doggo\"]`, expected a String at ``.",
|
||||||
|
"code": "invalid_settings_distinct_attribute",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-distinct-attribute"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -154,6 +242,17 @@ async fn settings_bad_typo_tolerance() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-typo-tolerance"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-typo-tolerance"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_typo_tolerance(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Map at ``.",
|
||||||
|
"code": "invalid_settings_typo_tolerance",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-typo-tolerance"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -171,6 +270,17 @@ async fn settings_bad_faceting() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-faceting"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-faceting"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_faceting(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Map at ``.",
|
||||||
|
"code": "invalid_settings_faceting",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-faceting"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -188,4 +298,15 @@ async fn settings_bad_pagination() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-settings-pagination"
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-pagination"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let (response, code) = index.update_settings_pagination(json!("doggo")).await;
|
||||||
|
snapshot!(code, @"400 Bad Request");
|
||||||
|
snapshot!(json_string!(response), @r###"
|
||||||
|
{
|
||||||
|
"message": "invalid type: String `\"doggo\"`, expected a Map at ``.",
|
||||||
|
"code": "invalid_settings_pagination",
|
||||||
|
"type": "invalid_request",
|
||||||
|
"link": "https://docs.meilisearch.com/errors#invalid-settings-pagination"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user