mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-26 16:21:07 +00:00
update tests & fix the broken code
This commit is contained in:
committed by
qdequele
parent
5e2861ff55
commit
27b3b53bc5
@ -16,8 +16,8 @@ static GLOBAL_SERVER: Lazy<Mutex<common::Server>> = Lazy::new(|| {
|
||||
// Search
|
||||
// q: Captain
|
||||
// limit: 3
|
||||
#[test]
|
||||
fn search_with_limit() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_limit() {
|
||||
let query = "q=captain&limit=3";
|
||||
|
||||
let expected = json!([
|
||||
@ -74,7 +74,7 @@ fn search_with_limit() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -82,8 +82,8 @@ fn search_with_limit() {
|
||||
// q: Captain
|
||||
// limit: 3
|
||||
// offset: 1
|
||||
#[test]
|
||||
fn search_with_offset() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_offset() {
|
||||
let query = "q=captain&limit=3&offset=1";
|
||||
|
||||
let expected = json!([
|
||||
@ -141,7 +141,7 @@ fn search_with_offset() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -149,8 +149,8 @@ fn search_with_offset() {
|
||||
// q: Captain
|
||||
// limit: 1
|
||||
// attributeToHighlight: *
|
||||
#[test]
|
||||
fn search_with_attribute_to_highlight_wildcard() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_attribute_to_highlight_wildcard() {
|
||||
let query = "q=captain&limit=1&attributesToHighlight=*";
|
||||
|
||||
let expected = json!([
|
||||
@ -190,7 +190,7 @@ fn search_with_attribute_to_highlight_wildcard() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -198,8 +198,8 @@ fn search_with_attribute_to_highlight_wildcard() {
|
||||
// q: Captain
|
||||
// limit: 1
|
||||
// attributeToHighlight: title
|
||||
#[test]
|
||||
fn search_with_attribute_to_highlight_1() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_attribute_to_highlight_1() {
|
||||
let query = "q=captain&limit=1&attributesToHighlight=title";
|
||||
|
||||
let expected = json!([
|
||||
@ -239,7 +239,7 @@ fn search_with_attribute_to_highlight_1() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -247,8 +247,8 @@ fn search_with_attribute_to_highlight_1() {
|
||||
// q: Captain
|
||||
// limit: 1
|
||||
// attributeToHighlight: title,tagline
|
||||
#[test]
|
||||
fn search_with_attribute_to_highlight_title_tagline() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_attribute_to_highlight_title_tagline() {
|
||||
let query = "q=captain&limit=1&attributesToHighlight=title,tagline";
|
||||
|
||||
let expected = json!([
|
||||
@ -288,7 +288,7 @@ fn search_with_attribute_to_highlight_title_tagline() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -296,8 +296,8 @@ fn search_with_attribute_to_highlight_title_tagline() {
|
||||
// q: Captain
|
||||
// limit: 1
|
||||
// attributeToHighlight: title,overview
|
||||
#[test]
|
||||
fn search_with_attribute_to_highlight_title_overview() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_attribute_to_highlight_title_overview() {
|
||||
let query = "q=captain&limit=1&attributesToHighlight=title,overview";
|
||||
|
||||
let expected = json!([
|
||||
@ -337,7 +337,7 @@ fn search_with_attribute_to_highlight_title_overview() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -345,8 +345,8 @@ fn search_with_attribute_to_highlight_title_overview() {
|
||||
// q: Captain
|
||||
// limit: 1
|
||||
// matches: true
|
||||
#[test]
|
||||
fn search_with_matches() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_matches() {
|
||||
let query = "q=captain&limit=1&matches=true";
|
||||
|
||||
let expected = json!([
|
||||
@ -383,7 +383,7 @@ fn search_with_matches() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -392,8 +392,8 @@ fn search_with_matches() {
|
||||
// limit: 1
|
||||
// attributesToCrop: overview
|
||||
// cropLength: 20
|
||||
#[test]
|
||||
fn search_witch_crop() {
|
||||
#[actix_rt::test]
|
||||
async fn search_witch_crop() {
|
||||
let query = "q=captain&limit=1&attributesToCrop=overview&cropLength=20";
|
||||
|
||||
let expected = json!([
|
||||
@ -433,7 +433,7 @@ fn search_witch_crop() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -441,8 +441,8 @@ fn search_witch_crop() {
|
||||
// q: Captain
|
||||
// limit: 1
|
||||
// attributesToRetrieve: [title,tagline,overview,poster_path]
|
||||
#[test]
|
||||
fn search_with_attributes_to_retrieve() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_attributes_to_retrieve() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=title,tagline,overview,poster_path";
|
||||
|
||||
let expected = json!([
|
||||
@ -454,7 +454,7 @@ fn search_with_attributes_to_retrieve() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -462,8 +462,8 @@ fn search_with_attributes_to_retrieve() {
|
||||
// q: Captain
|
||||
// limit: 1
|
||||
// attributesToRetrieve: *
|
||||
#[test]
|
||||
fn search_with_attributes_to_retrieve_wildcard() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_attributes_to_retrieve_wildcard() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=*";
|
||||
|
||||
let expected = json!([
|
||||
@ -486,7 +486,7 @@ fn search_with_attributes_to_retrieve_wildcard() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -494,8 +494,8 @@ fn search_with_attributes_to_retrieve_wildcard() {
|
||||
// q: Captain
|
||||
// limit: 3
|
||||
// filters: director:Anthony%20Russo
|
||||
#[test]
|
||||
fn search_with_filter() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_filter() {
|
||||
let query = "q=captain&filters=director%20%3D%20%22Anthony%20Russo%22&limit=3";
|
||||
let expected = json!([
|
||||
{
|
||||
@ -744,8 +744,8 @@ fn search_with_filter() {
|
||||
// limit: 1
|
||||
// attributesToHighlight: [title,overview]
|
||||
// matches: true
|
||||
#[test]
|
||||
fn search_with_attributes_to_highlight_and_matches() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_attributes_to_highlight_and_matches() {
|
||||
let query = "q=captain&limit=1&attributesToHighlight=title,overview&matches=true";
|
||||
|
||||
let expected = json!( [
|
||||
@ -799,7 +799,7 @@ fn search_with_attributes_to_highlight_and_matches() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -810,8 +810,8 @@ fn search_with_attributes_to_highlight_and_matches() {
|
||||
// matches: true
|
||||
// cropLength: 20
|
||||
// attributesToCrop: overview
|
||||
#[test]
|
||||
fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
||||
let query = "q=captain&limit=1&attributesToCrop=overview&cropLength=20&attributesToHighlight=title,overview&matches=true";
|
||||
|
||||
let expected = json!([
|
||||
@ -865,7 +865,7 @@ fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -874,8 +874,8 @@ fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
||||
// limit: 1
|
||||
// attributesToRetrieve: [title,producer,director]
|
||||
// attributesToHighlight: [title]
|
||||
#[test]
|
||||
fn search_with_differents_attributes() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_differents_attributes() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToHighlight=title";
|
||||
|
||||
let expected = json!([
|
||||
@ -889,7 +889,7 @@ fn search_with_differents_attributes() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -899,8 +899,8 @@ fn search_with_differents_attributes() {
|
||||
// attributesToRetrieve: [title,producer,director]
|
||||
// attributesToCrop: [overview]
|
||||
// cropLength: 10
|
||||
#[test]
|
||||
fn search_with_differents_attributes_2() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_differents_attributes_2() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=overview&cropLength=10";
|
||||
|
||||
let expected = json!([
|
||||
@ -914,7 +914,7 @@ fn search_with_differents_attributes_2() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -923,8 +923,8 @@ fn search_with_differents_attributes_2() {
|
||||
// limit: 1
|
||||
// attributesToRetrieve: [title,producer,director]
|
||||
// attributesToCrop: [overview:10]
|
||||
#[test]
|
||||
fn search_with_differents_attributes_3() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_differents_attributes_3() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=overview:10";
|
||||
|
||||
let expected = json!([
|
||||
@ -938,7 +938,7 @@ fn search_with_differents_attributes_3() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -947,8 +947,8 @@ fn search_with_differents_attributes_3() {
|
||||
// limit: 1
|
||||
// attributesToRetrieve: [title,producer,director]
|
||||
// attributesToCrop: [overview:10,title:0]
|
||||
#[test]
|
||||
fn search_with_differents_attributes_4() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_differents_attributes_4() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=overview:10,title:0";
|
||||
|
||||
let expected = json!([
|
||||
@ -963,7 +963,7 @@ fn search_with_differents_attributes_4() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -972,8 +972,8 @@ fn search_with_differents_attributes_4() {
|
||||
// limit: 1
|
||||
// attributesToRetrieve: [title,producer,director]
|
||||
// attributesToCrop: [*,overview:10]
|
||||
#[test]
|
||||
fn search_with_differents_attributes_5() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_differents_attributes_5() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10";
|
||||
|
||||
let expected = json!([
|
||||
@ -990,7 +990,7 @@ fn search_with_differents_attributes_5() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -1000,8 +1000,8 @@ fn search_with_differents_attributes_5() {
|
||||
// attributesToRetrieve: [title,producer,director]
|
||||
// attributesToCrop: [*,overview:10]
|
||||
// attributesToHighlight: [title]
|
||||
#[test]
|
||||
fn search_with_differents_attributes_6() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_differents_attributes_6() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10&attributesToHighlight=title";
|
||||
|
||||
let expected = json!([
|
||||
@ -1018,7 +1018,7 @@ fn search_with_differents_attributes_6() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -1028,8 +1028,8 @@ fn search_with_differents_attributes_6() {
|
||||
// attributesToRetrieve: [title,producer,director]
|
||||
// attributesToCrop: [*,overview:10]
|
||||
// attributesToHighlight: [*]
|
||||
#[test]
|
||||
fn search_with_differents_attributes_7() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_differents_attributes_7() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10&attributesToHighlight=*";
|
||||
|
||||
let expected = json!([
|
||||
@ -1046,7 +1046,7 @@ fn search_with_differents_attributes_7() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
||||
@ -1056,8 +1056,8 @@ fn search_with_differents_attributes_7() {
|
||||
// attributesToRetrieve: [title,producer,director]
|
||||
// attributesToCrop: [*,overview:10]
|
||||
// attributesToHighlight: [*,tagline]
|
||||
#[test]
|
||||
fn search_with_differents_attributes_8() {
|
||||
#[actix_rt::test]
|
||||
async fn search_with_differents_attributes_8() {
|
||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10&attributesToHighlight=*,tagline";
|
||||
|
||||
let expected = json!([
|
||||
@ -1075,6 +1075,6 @@ fn search_with_differents_attributes_8() {
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user