From 0a67248bfeaabc083f0401ecd3278737e27d3ac1 Mon Sep 17 00:00:00 2001 From: qdequele Date: Mon, 17 Aug 2020 17:03:57 +0200 Subject: [PATCH] cargo fmt --- meilisearch-http/src/routes/document.rs | 15 +++++++-------- meilisearch-http/tests/documents_add.rs | 9 ++++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/meilisearch-http/src/routes/document.rs b/meilisearch-http/src/routes/document.rs index 78d8345d6..9290a8710 100644 --- a/meilisearch-http/src/routes/document.rs +++ b/meilisearch-http/src/routes/document.rs @@ -3,14 +3,14 @@ use std::collections::{BTreeSet, HashSet}; use actix_web::{delete, get, post, put}; use actix_web::{web, HttpResponse}; use indexmap::IndexMap; -use meilisearch_core::{update, MainReader}; +use meilisearch_core::{update, Index}; use serde_json::Value; use serde::Deserialize; -use crate::Data; use crate::error::{Error, ResponseError}; use crate::helpers::Authentication; use crate::routes::{IndexParam, IndexUpdateResponse}; +use crate::Data; type Document = IndexMap; @@ -45,7 +45,8 @@ async fn get_document( let reader = data.db.main_read_txn()?; - let internal_id = index.main + let internal_id = index + .main .external_to_internal_docid(&reader, &path.document_id)? .ok_or(Error::document_not_found(&path.document_id))?; @@ -189,6 +190,7 @@ fn create_index(data: &Data, uid: &str) -> Result { Ok(created_index) } + async fn update_multiple_documents( data: web::Data, path: web::Path, @@ -215,12 +217,10 @@ async fn update_multiple_documents( None => body .first() .and_then(find_primary_key) - .ok_or(meilisearch_core::Error::MissingPrimaryKey)? + .ok_or(meilisearch_core::Error::MissingPrimaryKey)?, }; - schema - .set_primary_key(&id) - .map_err(Error::bad_request)?; + schema.set_primary_key(&id).map_err(Error::bad_request)?; data.db.main_write(|w| index.main.put_schema(w, &schema))?; } @@ -274,7 +274,6 @@ async fn delete_documents( .open_index(&path.index_uid) .ok_or(Error::index_not_found(&path.index_uid))?; - let mut documents_deletion = index.documents_deletion(); for document_id in body.into_inner() { diff --git a/meilisearch-http/tests/documents_add.rs b/meilisearch-http/tests/documents_add.rs index b4a7a8afc..140a194c3 100644 --- a/meilisearch-http/tests/documents_add.rs +++ b/meilisearch-http/tests/documents_add.rs @@ -192,7 +192,9 @@ async fn add_document_with_long_field() { "url":"/configuration/app/web.html#locations" }]); server.add_or_replace_multiple_documents(body).await; - let (response, _status) = server.search_post(json!({ "q": "request_buffering" })).await; + let (response, _status) = server + .search_post(json!({ "q": "request_buffering" })) + .await; assert!(!response["hits"].as_array().unwrap().is_empty()); } @@ -213,6 +215,11 @@ async fn documents_with_same_id_are_overwritten() { server.add_or_replace_multiple_documents(documents).await; let (response, _status) = server.get_all_documents().await; assert_eq!(response.as_array().unwrap().len(), 1); + assert_eq!( + response.as_array().unwrap()[0].as_object().unwrap()["content"], + "test2" + ); +} #[actix_rt::test] async fn create_index_lazy_by_pushing_documents() {