From 7ece7a9d9ee3015a84f3b19f6b7360b7099b5388 Mon Sep 17 00:00:00 2001 From: Liu Hancheng Date: Thu, 31 Mar 2022 10:39:21 +0800 Subject: [PATCH] change truncate strategy and coresponding test --- meilisearch-http/tests/documents/add_documents.rs | 5 ++--- meilisearch-lib/src/document_formats.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/meilisearch-http/tests/documents/add_documents.rs b/meilisearch-http/tests/documents/add_documents.rs index 5401112ab..1904f4979 100644 --- a/meilisearch-http/tests/documents/add_documents.rs +++ b/meilisearch-http/tests/documents/add_documents.rs @@ -1,6 +1,5 @@ use crate::common::{GetAllDocumentsOptions, Server}; use actix_web::test; -use itertools::Itertools; use meilisearch_http::{analytics, create_app}; use serde_json::{json, Value}; use time::{format_description::well_known::Rfc3339, OffsetDateTime}; @@ -329,7 +328,7 @@ async fn error_add_malformed_json_documents() { assert_eq!( response["message"], json!( - r#"The `json` payload provided is malformed. `Couldn't serialize document value: invalid type: string "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", expected a documents, or a sequence of documents. at line 1 column 102`."# + r#"The `json` payload provided is malformed. `Couldn't serialize document value: invalid type: string "0123456789012345678901234567...890123456789", expected a documents, or a sequence of documents. at line 1 column 102`."# ) ); assert_eq!(response["code"], json!("malformed_payload")); @@ -355,7 +354,7 @@ async fn error_add_malformed_json_documents() { assert_eq!( response["message"], json!( - r#"The `json` payload provided is malformed. `Couldn't serialize document value: invalid type: string "01234567890123456789012345678901234567890123456789 ... 1234567890123456789012345678901234567890123456789m", expected a documents, or a sequence of documents. at line 1 column 103`."# + r#"The `json` payload provided is malformed. `Couldn't serialize document value: invalid type: string "0123456789012345678901234567...90123456789m", expected a documents, or a sequence of documents. at line 1 column 103`."# ) ); assert_eq!(response["code"], json!("malformed_payload")); diff --git a/meilisearch-lib/src/document_formats.rs b/meilisearch-lib/src/document_formats.rs index 27097a81b..93c47afe8 100644 --- a/meilisearch-lib/src/document_formats.rs +++ b/meilisearch-lib/src/document_formats.rs @@ -41,7 +41,7 @@ impl Display for DocumentFormatError { let mut serde_msg = se.to_string(); let ellipsis = "..."; if serde_msg.len() > 100 + ellipsis.len() { - serde_msg.replace_range(50..serde_msg.len() - 50, ellipsis); + serde_msg.replace_range(50..serde_msg.len() - 85, ellipsis); } write!(