From 1746132c7dd40b7534e042ce89e64975ade2b5e0 Mon Sep 17 00:00:00 2001 From: Marin Postma Date: Tue, 6 Apr 2021 17:56:25 +0200 Subject: [PATCH] add test set/reset distinct attribute --- meilisearch-http/tests/settings/distinct.rs | 23 +++++++++++++++++++ .../tests/settings/get_settings.rs | 1 + meilisearch-http/tests/settings/mod.rs | 1 + 3 files changed, 25 insertions(+) create mode 100644 meilisearch-http/tests/settings/distinct.rs diff --git a/meilisearch-http/tests/settings/distinct.rs b/meilisearch-http/tests/settings/distinct.rs new file mode 100644 index 000000000..852276b99 --- /dev/null +++ b/meilisearch-http/tests/settings/distinct.rs @@ -0,0 +1,23 @@ +use crate::common::Server; +use serde_json::{json, Value}; + +#[actix_rt::test] +async fn set_and_reset_distinct_attribute() { + let server = Server::new().await; + let index = server.index("test"); + + let (_response, _code) = index.update_settings(json!({ "distinctAttribute": "test"})).await; + index.wait_update_id(0).await; + + let (response, _) = index.settings().await; + + assert_eq!(response["distinctAttribute"], "test"); + + index.update_settings(json!({ "distinctAttribute": Value::Null })).await; + + index.wait_update_id(1).await; + + let (response, _) = index.settings().await; + + assert_eq!(response["distinctAttribute"], Value::Null); +} diff --git a/meilisearch-http/tests/settings/get_settings.rs b/meilisearch-http/tests/settings/get_settings.rs index be09a5090..d83a778cc 100644 --- a/meilisearch-http/tests/settings/get_settings.rs +++ b/meilisearch-http/tests/settings/get_settings.rs @@ -20,6 +20,7 @@ async fn get_settings() { assert_eq!(settings["displayedAttributes"], json!(["*"])); assert_eq!(settings["searchableAttributes"], json!(["*"])); assert_eq!(settings["attributesForFaceting"], json!({})); + assert_eq!(settings["distinctAttribute"], serde_json::Value::Null); assert_eq!( settings["rankingRules"], json!([ diff --git a/meilisearch-http/tests/settings/mod.rs b/meilisearch-http/tests/settings/mod.rs index c9e93c85d..b7102cc5f 100644 --- a/meilisearch-http/tests/settings/mod.rs +++ b/meilisearch-http/tests/settings/mod.rs @@ -1 +1,2 @@ mod get_settings; +mod distinct;