mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
add tests for post search route
This commit is contained in:
parent
0ebf7b6214
commit
26d29783ce
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -1604,6 +1604,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_qs",
|
||||
"serde_url_params",
|
||||
"sha2",
|
||||
"siphasher",
|
||||
"slice-group-by",
|
||||
@ -2476,6 +2477,16 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_url_params"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d24680ccd1ad7cdee9e8affa70f37d081b3d14d3800d33a28f474d0f7a55f305"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.6.1"
|
||||
|
@ -73,6 +73,7 @@ optional = true
|
||||
[dev-dependencies]
|
||||
tempdir = "0.3.7"
|
||||
tokio = { version = "0.2.18", features = ["macros", "time"] }
|
||||
serde_url_params = "0.2.0"
|
||||
|
||||
[dev-dependencies.assert-json-diff]
|
||||
git = "https://github.com/qdequele/assert-json-diff"
|
||||
|
@ -252,11 +252,16 @@ impl Server {
|
||||
self.delete_request(&url).await
|
||||
}
|
||||
|
||||
pub async fn search(&mut self, query: &str) -> (Value, StatusCode) {
|
||||
pub async fn search_get(&mut self, query: &str) -> (Value, StatusCode) {
|
||||
let url = format!("/indexes/{}/search?{}", self.uid, query);
|
||||
self.get_request(&url).await
|
||||
}
|
||||
|
||||
pub async fn search_post(&mut self, body: Value) -> (Value, StatusCode) {
|
||||
let url = format!("/indexes/{}/search", self.uid);
|
||||
self.post_request(&url, body).await
|
||||
}
|
||||
|
||||
pub async fn get_all_updates_status(&mut self) -> (Value, StatusCode) {
|
||||
let url = format!("/indexes/{}/updates", self.uid);
|
||||
self.get_request(&url).await
|
||||
|
@ -629,7 +629,7 @@ async fn create_index_without_primary_key_and_search() {
|
||||
|
||||
let query = "q=captain&limit=3";
|
||||
|
||||
let (response, status_code) = server.search(&query).await;
|
||||
let (response, status_code) = server.search_get(&query).await;
|
||||
assert_eq!(status_code, 200);
|
||||
assert_eq!(response["hits"].as_array().unwrap().len(), 0);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -106,7 +106,7 @@ async fn search_with_settings_basic() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = server.search(query).await;
|
||||
let (response, _status_code) = server.search_get(query).await;
|
||||
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ async fn search_with_settings_stop_words() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = server.search(query).await;
|
||||
let (response, _status_code) = server.search_get(query).await;
|
||||
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ async fn search_with_settings_synonyms() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = server.search(query).await;
|
||||
let (response, _status_code) = server.search_get(query).await;
|
||||
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -429,7 +429,7 @@ async fn search_with_settings_ranking_rules() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = server.search(query).await;
|
||||
let (response, _status_code) = server.search_get(query).await;
|
||||
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -534,7 +534,7 @@ async fn search_with_settings_searchable_attributes() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = server.search(query).await;
|
||||
let (response, _status_code) = server.search_get(query).await;
|
||||
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -604,7 +604,7 @@ async fn search_with_settings_displayed_attributes() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = server.search(query).await;
|
||||
let (response, _status_code) = server.search_get(query).await;
|
||||
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -674,6 +674,6 @@ async fn search_with_settings_searchable_attributes_2() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = server.search(query).await;
|
||||
let (response, _status_code) = server.search_get(query).await;
|
||||
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ async fn add_documents_and_stop_words() {
|
||||
|
||||
// 3 - Search for a document with stop words
|
||||
|
||||
let (response, _status_code) = server.search("q=the%20mask").await;
|
||||
let (response, _status_code) = server.search_get("q=the%20mask").await;
|
||||
assert!(!response["hits"].as_array().unwrap().is_empty());
|
||||
|
||||
// 4 - Search for documents with *only* stop words
|
||||
|
||||
let (response, _status_code) = server.search("q=the%20of").await;
|
||||
let (response, _status_code) = server.search_get("q=the%20of").await;
|
||||
assert!(response["hits"].as_array().unwrap().is_empty());
|
||||
|
||||
// 5 - Delete all stop words
|
||||
|
Loading…
Reference in New Issue
Block a user