mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
fix tests
This commit is contained in:
parent
e8bd5ea4e0
commit
11c81ab4cb
@ -4,7 +4,7 @@ use actix_web::{get, HttpResponse};
|
|||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::index::Settings;
|
use crate::index::{Settings, Unchecked};
|
||||||
use crate::index_controller::{UpdateMeta, UpdateResult, UpdateStatus};
|
use crate::index_controller::{UpdateMeta, UpdateResult, UpdateStatus};
|
||||||
|
|
||||||
pub mod document;
|
pub mod document;
|
||||||
@ -34,7 +34,7 @@ pub enum UpdateType {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
number: Option<usize>
|
number: Option<usize>
|
||||||
},
|
},
|
||||||
Settings { settings: Settings },
|
Settings { settings: Settings<Unchecked> },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&UpdateStatus> for UpdateType {
|
impl From<&UpdateStatus> for UpdateType {
|
||||||
@ -60,20 +60,12 @@ impl From<&UpdateStatus> for UpdateType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
UpdateMeta::ClearDocuments => UpdateType::ClearAll,
|
UpdateMeta::ClearDocuments => UpdateType::ClearAll,
|
||||||
UpdateMeta::DeleteDocuments => {
|
UpdateMeta::DeleteDocuments { ids } => {
|
||||||
let number = match other {
|
UpdateType::DocumentsDeletion { number: Some(ids.len()) }
|
||||||
UpdateStatus::Processed(processed) => match processed.success {
|
|
||||||
UpdateResult::DocumentDeletion { deleted } => Some(deleted as usize),
|
|
||||||
_ => None,
|
|
||||||
},
|
|
||||||
_ => None,
|
|
||||||
};
|
|
||||||
UpdateType::DocumentsDeletion { number }
|
|
||||||
}
|
}
|
||||||
UpdateMeta::Settings(settings) => UpdateType::Settings {
|
UpdateMeta::Settings(settings) => UpdateType::Settings {
|
||||||
settings: settings.clone(),
|
settings: settings.clone(),
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,16 +33,14 @@ async fn add_documents_no_index_creation() {
|
|||||||
assert_eq!(code, 200);
|
assert_eq!(code, 200);
|
||||||
assert_eq!(response["status"], "processed");
|
assert_eq!(response["status"], "processed");
|
||||||
assert_eq!(response["updateId"], 0);
|
assert_eq!(response["updateId"], 0);
|
||||||
assert_eq!(response["success"]["DocumentsAddition"]["nb_documents"], 1);
|
assert_eq!(response["type"]["name"], "DocumentsAddition");
|
||||||
|
assert_eq!(response["type"]["number"], 1);
|
||||||
|
|
||||||
let processed_at =
|
let processed_at =
|
||||||
DateTime::parse_from_rfc3339(response["processedAt"].as_str().unwrap()).unwrap();
|
DateTime::parse_from_rfc3339(response["processedAt"].as_str().unwrap()).unwrap();
|
||||||
let enqueued_at =
|
let enqueued_at =
|
||||||
DateTime::parse_from_rfc3339(response["enqueuedAt"].as_str().unwrap()).unwrap();
|
DateTime::parse_from_rfc3339(response["enqueuedAt"].as_str().unwrap()).unwrap();
|
||||||
let started_processing_at =
|
assert!(processed_at > enqueued_at);
|
||||||
DateTime::parse_from_rfc3339(response["startedProcessingAt"].as_str().unwrap()).unwrap();
|
|
||||||
assert!(processed_at > started_processing_at);
|
|
||||||
assert!(started_processing_at > enqueued_at);
|
|
||||||
|
|
||||||
// index was created, and primary key was infered.
|
// index was created, and primary key was infered.
|
||||||
let (response, code) = index.get().await;
|
let (response, code) = index.get().await;
|
||||||
@ -86,7 +84,8 @@ async fn document_addition_with_primary_key() {
|
|||||||
assert_eq!(code, 200);
|
assert_eq!(code, 200);
|
||||||
assert_eq!(response["status"], "processed");
|
assert_eq!(response["status"], "processed");
|
||||||
assert_eq!(response["updateId"], 0);
|
assert_eq!(response["updateId"], 0);
|
||||||
assert_eq!(response["success"]["DocumentsAddition"]["nb_documents"], 1);
|
assert_eq!(response["type"]["name"], "DocumentsAddition");
|
||||||
|
assert_eq!(response["type"]["number"], 1);
|
||||||
|
|
||||||
let (response, code) = index.get().await;
|
let (response, code) = index.get().await;
|
||||||
assert_eq!(code, 200);
|
assert_eq!(code, 200);
|
||||||
@ -113,7 +112,8 @@ async fn document_update_with_primary_key() {
|
|||||||
assert_eq!(code, 200);
|
assert_eq!(code, 200);
|
||||||
assert_eq!(response["status"], "processed");
|
assert_eq!(response["status"], "processed");
|
||||||
assert_eq!(response["updateId"], 0);
|
assert_eq!(response["updateId"], 0);
|
||||||
assert_eq!(response["success"]["DocumentsAddition"]["nb_documents"], 1);
|
assert_eq!(response["type"]["name"], "DocumentsPartial");
|
||||||
|
assert_eq!(response["type"]["number"], 1);
|
||||||
|
|
||||||
let (response, code) = index.get().await;
|
let (response, code) = index.get().await;
|
||||||
assert_eq!(code, 200);
|
assert_eq!(code, 200);
|
||||||
@ -282,7 +282,8 @@ async fn add_larger_dataset() {
|
|||||||
let (response, code) = index.get_update(update_id).await;
|
let (response, code) = index.get_update(update_id).await;
|
||||||
assert_eq!(code, 200);
|
assert_eq!(code, 200);
|
||||||
assert_eq!(response["status"], "processed");
|
assert_eq!(response["status"], "processed");
|
||||||
assert_eq!(response["success"]["DocumentsAddition"]["nb_documents"], 77);
|
assert_eq!(response["type"]["name"], "DocumentsAddition");
|
||||||
|
assert_eq!(response["type"]["number"], 77);
|
||||||
let (response, code) = index
|
let (response, code) = index
|
||||||
.get_all_documents(GetAllDocumentsOptions {
|
.get_all_documents(GetAllDocumentsOptions {
|
||||||
limit: Some(1000),
|
limit: Some(1000),
|
||||||
@ -302,8 +303,8 @@ async fn update_larger_dataset() {
|
|||||||
index.wait_update_id(0).await;
|
index.wait_update_id(0).await;
|
||||||
let (response, code) = index.get_update(0).await;
|
let (response, code) = index.get_update(0).await;
|
||||||
assert_eq!(code, 200);
|
assert_eq!(code, 200);
|
||||||
assert_eq!(response["status"], "processed");
|
assert_eq!(response["type"]["name"], "DocumentsPartial");
|
||||||
assert_eq!(response["success"]["DocumentsAddition"]["nb_documents"], 77);
|
assert_eq!(response["type"]["number"], 77);
|
||||||
let (response, code) = index
|
let (response, code) = index
|
||||||
.get_all_documents(GetAllDocumentsOptions {
|
.get_all_documents(GetAllDocumentsOptions {
|
||||||
limit: Some(1000),
|
limit: Some(1000),
|
||||||
|
Loading…
Reference in New Issue
Block a user