From 3d771f22897320d3f0025ed93ca90d6bae5a38b0 Mon Sep 17 00:00:00 2001 From: mpostma Date: Tue, 16 Jun 2020 11:55:58 +0200 Subject: [PATCH] test distinct attribute --- meilisearch-http/tests/settings.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/meilisearch-http/tests/settings.rs b/meilisearch-http/tests/settings.rs index 5716860b9..499c2dba9 100644 --- a/meilisearch-http/tests/settings.rs +++ b/meilisearch-http/tests/settings.rs @@ -469,3 +469,19 @@ async fn setting_ranking_rules_dont_mess_with_other_settings() { assert!(!response["searchableAttributes"].as_array().unwrap().iter().any(|e| e.as_str().unwrap() == "foobar")); assert!(!response["displayedAttributes"].as_array().unwrap().iter().any(|e| e.as_str().unwrap() == "foobar")); } + +#[actix_rt::test] +async fn distinct_attribute_recorded_as_known_field() { + let mut server = common::Server::test_server().await; + let body = json!({ + "distinctAttribute": "foobar", + "acceptNewFields": true + }); + server.update_all_settings(body).await; + let document = json!([{"id": 9348127, "foobar": "hello", "foo": "bar"}]); + server.add_or_update_multiple_documents(document).await; + // foobar should not be added to the searchable attributes because it is already known, but "foo" should + let (response, _) = server.get_all_settings().await; + assert!(response["searchableAttributes"].as_array().unwrap().iter().any(|v| v.as_str().unwrap() == "foo")); + assert!(!response["searchableAttributes"].as_array().unwrap().iter().any(|v| v.as_str().unwrap() == "foobar")); +}