2023-07-24 17:00:18 +02:00
|
|
|
use meili_snap::{json_string, snapshot};
|
2023-07-19 18:15:48 +02:00
|
|
|
use serde_json::json;
|
|
|
|
|
|
|
|
use crate::common::Server;
|
|
|
|
|
|
|
|
#[actix_rt::test]
|
|
|
|
async fn set_and_reset() {
|
|
|
|
let server = Server::new().await;
|
|
|
|
let index = server.index("test");
|
|
|
|
|
|
|
|
let (_response, _code) = index
|
|
|
|
.update_settings(json!({
|
2023-07-24 17:00:18 +02:00
|
|
|
"nonSeparatorTokens": ["#", "&"],
|
|
|
|
"separatorTokens": ["&sep", "<br/>"],
|
2023-07-19 18:15:48 +02:00
|
|
|
"dictionary": ["J.R.R.", "J. R. R."],
|
|
|
|
}))
|
|
|
|
.await;
|
|
|
|
index.wait_task(0).await;
|
|
|
|
|
|
|
|
let (response, _) = index.settings().await;
|
2023-07-24 17:00:18 +02:00
|
|
|
snapshot!(json_string!(response["nonSeparatorTokens"]), @r###"
|
|
|
|
[
|
|
|
|
"#",
|
|
|
|
"&"
|
|
|
|
]
|
|
|
|
"###);
|
|
|
|
snapshot!(json_string!(response["separatorTokens"]), @r###"
|
|
|
|
[
|
|
|
|
"&sep",
|
|
|
|
"<br/>"
|
|
|
|
]
|
|
|
|
"###);
|
|
|
|
snapshot!(json_string!(response["dictionary"]), @r###"
|
|
|
|
[
|
|
|
|
"J. R. R.",
|
|
|
|
"J.R.R."
|
|
|
|
]
|
|
|
|
"###);
|
2023-07-19 18:15:48 +02:00
|
|
|
|
|
|
|
index
|
|
|
|
.update_settings(json!({
|
2023-07-24 17:00:18 +02:00
|
|
|
"nonSeparatorTokens": null,
|
|
|
|
"separatorTokens": null,
|
2023-07-19 18:15:48 +02:00
|
|
|
"dictionary": null,
|
|
|
|
}))
|
|
|
|
.await;
|
|
|
|
|
|
|
|
index.wait_task(1).await;
|
|
|
|
|
|
|
|
let (response, _) = index.settings().await;
|
2023-07-24 17:00:18 +02:00
|
|
|
snapshot!(json_string!(response["nonSeparatorTokens"]), @"[]");
|
|
|
|
snapshot!(json_string!(response["separatorTokens"]), @"[]");
|
|
|
|
snapshot!(json_string!(response["dictionary"]), @"[]");
|
2023-07-19 18:15:48 +02:00
|
|
|
}
|