mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-23 13:10:06 +01:00
update tests
This commit is contained in:
parent
4986adc186
commit
ce8e12c7c5
@ -93,11 +93,7 @@ impl DataInner {
|
||||
let frequency: HashMap<_, _> = fields_frequency
|
||||
.into_iter()
|
||||
.filter_map(|(a, c)| {
|
||||
if let Some(name) = schema.name(a) {
|
||||
return Some((name.to_string(), c));
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
schema.name(a).map(|name| (name.to_string(), c))
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -302,7 +302,7 @@ impl<'a> SearchBuilder<'a> {
|
||||
Err(err) => error!("Error during criteria builder; {:?}", err),
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
builder.push(DocumentId);
|
||||
return Ok(Some(builder.build()));
|
||||
@ -416,7 +416,7 @@ fn calculate_matches(
|
||||
if !attributes_to_retrieve.contains(attribute) {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
}
|
||||
if !schema.displayed_name().contains(attribute) {
|
||||
continue;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ pub fn main() -> Result<(), MainError> {
|
||||
let data = Data::new(opt.clone());
|
||||
|
||||
if env::var("MEILI_NO_ANALYTICS") == Err(NotPresent) {
|
||||
thread::spawn(|| analytics::analytics_sender());
|
||||
thread::spawn(analytics::analytics_sender);
|
||||
}
|
||||
|
||||
let data_cloned = data.clone();
|
||||
|
@ -82,8 +82,8 @@ pub async fn get_all(ctx: Request<Data>) -> SResult<Response> {
|
||||
let settings = Settings {
|
||||
ranking_rules: Some(ranking_rules),
|
||||
ranking_distinct: Some(ranking_distinct),
|
||||
searchable_attributes: searchable_attributes,
|
||||
displayed_attributes: displayed_attributes,
|
||||
searchable_attributes,
|
||||
displayed_attributes,
|
||||
stop_words: Some(stop_words),
|
||||
synonyms: Some(synonyms),
|
||||
index_new_fields: Some(index_new_fields),
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use serde_json::Value;
|
||||
use std::error::Error;
|
||||
use std::time::Duration;
|
||||
@ -97,9 +99,15 @@ pub fn enrich_server_with_movies_settings(
|
||||
let req = http::Request::post("/indexes/movies/settings")
|
||||
.body(Body::from(body))
|
||||
.unwrap();
|
||||
let _res = server.simulate(req).unwrap();
|
||||
let res = server.simulate(req).unwrap();
|
||||
|
||||
block_on(sleep(Duration::from_secs(5)));
|
||||
let mut buf = Vec::new();
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let response: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert!(response["updateId"].as_u64().is_some());
|
||||
|
||||
wait_update_id(server, response["updateId"].as_u64().unwrap());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -112,9 +120,15 @@ pub fn enrich_server_with_movies_documents(
|
||||
let req = http::Request::post("/indexes/movies/documents")
|
||||
.body(Body::from(body))
|
||||
.unwrap();
|
||||
let _res = server.simulate(req).unwrap();
|
||||
let res = server.simulate(req).unwrap();
|
||||
|
||||
block_on(sleep(Duration::from_secs(10)));
|
||||
let mut buf = Vec::new();
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let response: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert!(response["updateId"].as_u64().is_some());
|
||||
|
||||
wait_update_id(server, response["updateId"].as_u64().unwrap());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -141,5 +155,31 @@ pub fn update_config(server: &mut TestBackend<Service<Data>>, config: Value) {
|
||||
let res = server.simulate(req).unwrap();
|
||||
assert_eq!(res.status(), 202);
|
||||
|
||||
block_on(sleep(Duration::from_secs(5)));
|
||||
let mut buf = Vec::new();
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let response: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
assert!(response["updateId"].as_u64().is_some());
|
||||
|
||||
wait_update_id(server, response["updateId"].as_u64().unwrap());
|
||||
}
|
||||
|
||||
pub fn wait_update_id(server: &mut TestBackend<Service<Data>>, update_id: u64) {
|
||||
loop {
|
||||
let req = http::Request::get(format!("/indexes/movies/updates/{}", update_id))
|
||||
.body(Body::empty())
|
||||
.unwrap();
|
||||
|
||||
let res = server.simulate(req).unwrap();
|
||||
assert_eq!(res.status(), 200);
|
||||
|
||||
let mut buf = Vec::new();
|
||||
block_on(res.into_body().read_to_end(&mut buf)).unwrap();
|
||||
let response: Value = serde_json::from_slice(&buf).unwrap();
|
||||
|
||||
if response["status"] == "processed" {
|
||||
return
|
||||
}
|
||||
block_on(sleep(Duration::from_secs(1)));
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ fn create_index_with_name() {
|
||||
|
||||
assert_eq!(r1_name, "movies");
|
||||
assert_eq!(r1_uid.len(), 8);
|
||||
assert_eq!(r1_created_at.len(), 27);
|
||||
assert_eq!(r1_updated_at.len(), 27);
|
||||
assert!(r1_created_at.len() > 1);
|
||||
assert!(r1_updated_at.len() > 1);
|
||||
|
||||
// 2 - Check the list of indexes
|
||||
// Must have 1 index with the exact same content that the request 1
|
||||
@ -98,8 +98,8 @@ fn create_index_with_uid() {
|
||||
|
||||
assert_eq!(r1_name, "movies");
|
||||
assert_eq!(r1_uid, "movies");
|
||||
assert_eq!(r1_created_at.len(), 27);
|
||||
assert_eq!(r1_updated_at.len(), 27);
|
||||
assert!(r1_created_at.len() > 1);
|
||||
assert!(r1_updated_at.len() > 1);
|
||||
|
||||
// 2 - Check the list of indexes
|
||||
// Must have 1 index with the exact same content that the request 1
|
||||
@ -159,8 +159,8 @@ fn create_index_with_name_and_uid() {
|
||||
|
||||
assert_eq!(r1_name, "Films");
|
||||
assert_eq!(r1_uid, "fr_movies");
|
||||
assert_eq!(r1_created_at.len(), 27);
|
||||
assert_eq!(r1_updated_at.len(), 27);
|
||||
assert!(r1_created_at.len() > 1);
|
||||
assert!(r1_updated_at.len() > 1);
|
||||
|
||||
// 2 - Check the list of indexes
|
||||
// Must have 1 index with the exact same content that the request 1
|
||||
@ -218,8 +218,8 @@ fn rename_index() {
|
||||
|
||||
assert_eq!(r1_name, "movies");
|
||||
assert_eq!(r1_uid.len(), 8);
|
||||
assert_eq!(r1_created_at.len(), 27);
|
||||
assert_eq!(r1_updated_at.len(), 27);
|
||||
assert!(r1_created_at.len() > 1);
|
||||
assert!(r1_updated_at.len() > 1);
|
||||
|
||||
// 2 - Update an index name
|
||||
// Update "movies" to "TV Shows"
|
||||
@ -250,7 +250,7 @@ fn rename_index() {
|
||||
assert_eq!(r2_name, "TV Shows");
|
||||
assert_eq!(r2_uid, r1_uid);
|
||||
assert_eq!(r2_created_at, r1_created_at);
|
||||
assert_eq!(r2_updated_at.len(), 27);
|
||||
assert!(r2_updated_at.len() > 1);
|
||||
|
||||
// 3 - Check the list of indexes
|
||||
// Must have 1 index with the exact same content that the request 2
|
||||
@ -309,8 +309,8 @@ fn delete_index_and_recreate_it() {
|
||||
|
||||
assert_eq!(r1_name, "movies");
|
||||
assert_eq!(r1_uid.len(), 8);
|
||||
assert_eq!(r1_created_at.len(), 27);
|
||||
assert_eq!(r1_updated_at.len(), 27);
|
||||
assert!(r1_created_at.len() > 1);
|
||||
assert!(r1_updated_at.len() > 1);
|
||||
|
||||
// 2 - Check the list of indexes
|
||||
// Must have 1 index with the exact same content that the request 1
|
||||
@ -392,8 +392,8 @@ fn delete_index_and_recreate_it() {
|
||||
|
||||
assert_eq!(r1_name, "movies");
|
||||
assert_eq!(r1_uid.len(), 8);
|
||||
assert_eq!(r1_created_at.len(), 27);
|
||||
assert_eq!(r1_updated_at.len(), 27);
|
||||
assert!(r1_created_at.len() > 1);
|
||||
assert!(r1_updated_at.len() > 1);
|
||||
|
||||
// 6 - Check the list of indexes
|
||||
// Must have 1 index with the exact same content that the request 1
|
||||
@ -452,8 +452,8 @@ fn check_multiples_indexes() {
|
||||
|
||||
assert_eq!(r1_name, "movies");
|
||||
assert_eq!(r1_uid.len(), 8);
|
||||
assert_eq!(r1_created_at.len(), 27);
|
||||
assert_eq!(r1_updated_at.len(), 27);
|
||||
assert!(r1_created_at.len() > 1);
|
||||
assert!(r1_updated_at.len() > 1);
|
||||
|
||||
// 2 - Check the list of indexes
|
||||
// Must have 1 index with the exact same content that the request 1
|
||||
@ -507,8 +507,8 @@ fn check_multiples_indexes() {
|
||||
|
||||
assert_eq!(r3_name, "films");
|
||||
assert_eq!(r3_uid.len(), 8);
|
||||
assert_eq!(r3_created_at.len(), 27);
|
||||
assert_eq!(r3_updated_at.len(), 27);
|
||||
assert!(r3_created_at.len() > 1);
|
||||
assert!(r3_updated_at.len() > 1);
|
||||
|
||||
// 4 - Check the list of indexes
|
||||
// Must have 2 index with the exact same content that the request 1 and 3
|
||||
|
Loading…
x
Reference in New Issue
Block a user