requested changes

This commit is contained in:
mpostma 2020-07-16 16:12:23 +02:00
parent 4b5437a882
commit d114250ebb
4 changed files with 23 additions and 9 deletions

View file

@ -520,7 +520,7 @@ fn get_indexed_attributes(schema: &Schema) -> Vec<String> {
schema.indexed_name()
.iter()
.map(|s| s.to_string())
.collect::<Vec<String>>()
.collect()
}
}
@ -531,6 +531,6 @@ fn get_displayed_attributes(schema: &Schema) -> HashSet<String> {
schema.displayed_name()
.iter()
.map(|s| s.to_string())
.collect::<HashSet<String>>()
.collect()
}
}

View file

@ -435,6 +435,8 @@ async fn displayed_and_searchable_attributes_reset_to_wildcard() {
let (response, _) = server.get_all_settings().await;
assert_eq!(response["searchableAttributes"].as_array().unwrap().len(), 1);
assert_eq!(response["displayedAttributes"].as_array().unwrap().len(), 1);
assert_eq!(response["searchableAttributes"].as_array().unwrap()[0], "*");
assert_eq!(response["displayedAttributes"].as_array().unwrap()[0], "*");
@ -447,6 +449,22 @@ async fn displayed_and_searchable_attributes_reset_to_wildcard() {
server.update_all_settings(json!({ "searchableAttributes": [], "displayedAttributes": [] })).await;
let (response, _) = server.get_all_settings().await;
assert_eq!(response["searchableAttributes"].as_array().unwrap().len(), 1);
assert_eq!(response["displayedAttributes"].as_array().unwrap().len(), 1);
assert_eq!(response["searchableAttributes"].as_array().unwrap()[0], "*");
assert_eq!(response["displayedAttributes"].as_array().unwrap()[0], "*");
}
#[actix_rt::test]
async fn settings_that_contains_wildcard_is_wildcard() {
let mut server = common::Server::test_server().await;
server.update_all_settings(json!({ "searchableAttributes": ["color", "*"], "displayedAttributes": ["color", "*"] })).await;
let (response, _) = server.get_all_settings().await;
assert_eq!(response["searchableAttributes"].as_array().unwrap().len(), 1);
assert_eq!(response["displayedAttributes"].as_array().unwrap().len(), 1);
assert_eq!(response["searchableAttributes"].as_array().unwrap()[0], "*");
assert_eq!(response["displayedAttributes"].as_array().unwrap()[0], "*");
}