From cdcdc7bd20c07a387fdf0dc008b6396cda800200 Mon Sep 17 00:00:00 2001 From: Kishore Nallan Date: Wed, 14 Apr 2021 21:52:35 +0530 Subject: [PATCH] Ensure that req filter clause is merged in multi search. --- test/core_api_utils_test.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/core_api_utils_test.cpp b/test/core_api_utils_test.cpp index 6a2f863e..201d76b5 100644 --- a/test/core_api_utils_test.cpp +++ b/test/core_api_utils_test.cpp @@ -2,6 +2,7 @@ #include "collection.h" #include #include +#include #include "core_api_utils.h" class CoreAPIUtilsTest : public ::testing::Test { @@ -116,4 +117,24 @@ TEST_F(CoreAPIUtilsTest, StatefulRemoveDocs) { ASSERT_STREQ("Could not parse the filter query.", op.error().c_str()); collectionManager.drop_collection("coll1"); -} \ No newline at end of file +} + +TEST_F(CoreAPIUtilsTest, MultiSearchEmbeddedKeys) { + std::shared_ptr req = std::make_shared(); + std::shared_ptr res = std::make_shared(); + + req->params["filter_by"] = "user_id: 100"; + nlohmann::json body; + body["searches"] = nlohmann::json::array(); + nlohmann::json search; + search["collection"] = "users"; + search["filter_by"] = "age: > 100"; + body["searches"].push_back(search); + + req->body = body.dump(); + + post_multi_search(req, res); + + // ensure that req params are appended to (embedded params are also rolled into req params) + ASSERT_EQ("user_id: 100&&age: > 100", req->params["filter_by"]); +}