From 3fe3c8cf02c95ad06bda81c0d143f82f7047b078 Mon Sep 17 00:00:00 2001 From: mpostma Date: Wed, 3 Jun 2020 11:09:25 +0200 Subject: [PATCH] test attributes_for_faceting subroutes --- meilisearch-http/tests/settings.rs | 27 ++++++++++++++++--- .../tests/settings_accept_new_fields.rs | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/meilisearch-http/tests/settings.rs b/meilisearch-http/tests/settings.rs index ad2d8caab..dcbe5760f 100644 --- a/meilisearch-http/tests/settings.rs +++ b/meilisearch-http/tests/settings.rs @@ -120,7 +120,7 @@ async fn write_all_and_delete() { ], "stopWords": [], "synonyms": {}, - "attributesForFaceting": null, + "attributesForFaceting": [], "acceptNewFields": true, }); @@ -282,7 +282,7 @@ async fn test_default_settings() { "displayedAttributes": [], "stopWords": [], "synonyms": {}, - "attributesForFaceting": null, + "attributesForFaceting": [], "acceptNewFields": true, }); @@ -320,7 +320,7 @@ async fn test_default_settings_2() { ], "stopWords": [], "synonyms": {}, - "attributesForFaceting": null, + "attributesForFaceting": [], "acceptNewFields": true, }); @@ -428,7 +428,7 @@ async fn write_setting_and_update_partial() { "wolverine": ["xmen", "logan"], "logan": ["wolverine"], }, - "attributesForFaceting": null, + "attributesForFaceting": [], "acceptNewFields": false, }); @@ -436,3 +436,22 @@ async fn write_setting_and_update_partial() { assert_json_eq!(expected, response, ordered: false); } + +#[actix_rt::test] +async fn attributes_for_faceting_settings() { + let mut server = common::Server::test_server().await; + // initial attributes array should be empty + let (response, _status_code) = server.get_request("/indexes/test/settings/attributes-for-faceting").await; + assert_eq!(response, json!([])); + // add an attribute and test for its presence + let (_response, _status_code) = server.post_request_async( + "/indexes/test/settings/attributes-for-faceting", + json!(["foobar"])).await; + let (response, _status_code) = server.get_request("/indexes/test/settings/attributes-for-faceting").await; + assert_eq!(response, json!(["foobar"])); + // remove all attributes and test for emptiness + let (_response, _status_code) = server.delete_request_async( + "/indexes/test/settings/attributes-for-faceting").await; + let (response, _status_code) = server.get_request("/indexes/test/settings/attributes-for-faceting").await; + assert_eq!(response, json!([])); +} diff --git a/meilisearch-http/tests/settings_accept_new_fields.rs b/meilisearch-http/tests/settings_accept_new_fields.rs index 8d2ebe1d9..6cc14deed 100644 --- a/meilisearch-http/tests/settings_accept_new_fields.rs +++ b/meilisearch-http/tests/settings_accept_new_fields.rs @@ -341,7 +341,7 @@ async fn accept_new_fields_does_not_take_into_account_the_primary_key() { "displayedAttributes": ["title"], "stopWords": [], "synonyms": {}, - "attributesForFaceting": null, + "attributesForFaceting": [], "acceptNewFields": false, });