From 11c81ab4cb4998afc8511e2d007281f833939359 Mon Sep 17 00:00:00 2001 From: Marin Postma Date: Mon, 3 May 2021 14:21:09 +0200 Subject: [PATCH] fix tests --- meilisearch-http/src/routes/mod.rs | 16 ++++---------- .../tests/documents/add_documents.rs | 21 ++++++++++--------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index 71a62c457..e1db8147d 100644 --- a/meilisearch-http/src/routes/mod.rs +++ b/meilisearch-http/src/routes/mod.rs @@ -4,7 +4,7 @@ use actix_web::{get, HttpResponse}; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; -use crate::index::Settings; +use crate::index::{Settings, Unchecked}; use crate::index_controller::{UpdateMeta, UpdateResult, UpdateStatus}; pub mod document; @@ -34,7 +34,7 @@ pub enum UpdateType { #[serde(skip_serializing_if = "Option::is_none")] number: Option }, - Settings { settings: Settings }, + Settings { settings: Settings }, } impl From<&UpdateStatus> for UpdateType { @@ -60,20 +60,12 @@ impl From<&UpdateStatus> for UpdateType { } } UpdateMeta::ClearDocuments => UpdateType::ClearAll, - UpdateMeta::DeleteDocuments => { - let number = match other { - UpdateStatus::Processed(processed) => match processed.success { - UpdateResult::DocumentDeletion { deleted } => Some(deleted as usize), - _ => None, - }, - _ => None, - }; - UpdateType::DocumentsDeletion { number } + UpdateMeta::DeleteDocuments { ids } => { + UpdateType::DocumentsDeletion { number: Some(ids.len()) } } UpdateMeta::Settings(settings) => UpdateType::Settings { settings: settings.clone(), }, - _ => unreachable!(), } } } diff --git a/meilisearch-http/tests/documents/add_documents.rs b/meilisearch-http/tests/documents/add_documents.rs index 1ec84e046..5d2a91674 100644 --- a/meilisearch-http/tests/documents/add_documents.rs +++ b/meilisearch-http/tests/documents/add_documents.rs @@ -33,16 +33,14 @@ async fn add_documents_no_index_creation() { assert_eq!(code, 200); assert_eq!(response["status"], "processed"); 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 = DateTime::parse_from_rfc3339(response["processedAt"].as_str().unwrap()).unwrap(); let enqueued_at = DateTime::parse_from_rfc3339(response["enqueuedAt"].as_str().unwrap()).unwrap(); - let started_processing_at = - DateTime::parse_from_rfc3339(response["startedProcessingAt"].as_str().unwrap()).unwrap(); - assert!(processed_at > started_processing_at); - assert!(started_processing_at > enqueued_at); + assert!(processed_at > enqueued_at); // index was created, and primary key was infered. let (response, code) = index.get().await; @@ -86,7 +84,8 @@ async fn document_addition_with_primary_key() { assert_eq!(code, 200); assert_eq!(response["status"], "processed"); 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; assert_eq!(code, 200); @@ -113,7 +112,8 @@ async fn document_update_with_primary_key() { assert_eq!(code, 200); assert_eq!(response["status"], "processed"); 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; assert_eq!(code, 200); @@ -282,7 +282,8 @@ async fn add_larger_dataset() { let (response, code) = index.get_update(update_id).await; assert_eq!(code, 200); 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 .get_all_documents(GetAllDocumentsOptions { limit: Some(1000), @@ -302,8 +303,8 @@ async fn update_larger_dataset() { index.wait_update_id(0).await; let (response, code) = index.get_update(0).await; assert_eq!(code, 200); - assert_eq!(response["status"], "processed"); - assert_eq!(response["success"]["DocumentsAddition"]["nb_documents"], 77); + assert_eq!(response["type"]["name"], "DocumentsPartial"); + assert_eq!(response["type"]["number"], 77); let (response, code) = index .get_all_documents(GetAllDocumentsOptions { limit: Some(1000),