From 51472142c6d6d4d7f217fab9c4785320599eb28d Mon Sep 17 00:00:00 2001 From: Pedro Paulo de Amorim Date: Tue, 31 Mar 2020 12:00:13 +0100 Subject: [PATCH] Add test to check if nested null will be ignored --- meilisearch-http/tests/documents_add.rs | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/meilisearch-http/tests/documents_add.rs b/meilisearch-http/tests/documents_add.rs index ca87a8027..aeea3c0ba 100644 --- a/meilisearch-http/tests/documents_add.rs +++ b/meilisearch-http/tests/documents_add.rs @@ -76,3 +76,33 @@ fn check_add_documents_with_nested_boolean() { assert_eq!(status_code, 200); assert_eq!(response["status"], "processed"); } + +// Test issue https://github.com/meilisearch/MeiliSearch/issues/571 +#[test] +fn check_add_documents_with_nested_sequence() { + let mut server = common::Server::with_uid("tasks"); + + // 1 - Create the index with no primary_key + + let body = json!({ "uid": "tasks" }); + let (response, status_code) = server.create_index(body); + assert_eq!(status_code, 201); + assert_eq!(response["primaryKey"], json!(null)); + + // 2 - Add a document that contains a null in a nested object + + let body = serde_json::from_str("[{\"id\":0,\"foo\":{\"bar\":null}}]").unwrap(); + + let url = "/indexes/tasks/documents"; + let (response, status_code) = server.post_request(&url, body); + eprintln!("{:#?}", response); + assert_eq!(status_code, 202); + let update_id = response["updateId"].as_u64().unwrap(); + server.wait_update_id(update_id); + + // 3 - Check update sucess + + let (response, status_code) = server.get_update_status(update_id); + assert_eq!(status_code, 200); + assert_eq!(response["status"], "processed"); +} \ No newline at end of file