change truncate strategy and coresponding test

This commit is contained in:
Liu Hancheng 2022-03-31 10:39:21 +08:00
parent 403f03cb2c
commit 7ece7a9d9e
2 changed files with 3 additions and 4 deletions

View File

@ -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"));

View File

@ -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!(