From 9b67107f68fe873807f3b13ff7fc838e4ec61f41 Mon Sep 17 00:00:00 2001 From: Vladislav Oleshko Date: Sat, 14 Jan 2023 15:41:41 +0300 Subject: [PATCH 1/2] test(rdb): Add json dump & restore test Signed-off-by: Vladislav Oleshko --- src/server/rdb_test.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/server/rdb_test.cc b/src/server/rdb_test.cc index e4e55826eab9..6d0aedbf100f 100644 --- a/src/server/rdb_test.cc +++ b/src/server/rdb_test.cc @@ -316,4 +316,22 @@ TEST_F(RdbTest, HMapBugs) { EXPECT_EQ(2, CheckedInt({"hlen", "hmap1"})); } +TEST_F(RdbTest, JsonTest) { + string_view data[] = { + R"({"a":1})"sv, // + R"([1,2,3,4,5,6])"sv, // + R"({"a":1.0,"b":[1,2],"c":"value"})"sv, // + R"({"a":{"a":{"a":{"a":1}}}})"sv // + }; + + for (auto test : data) { + Run({"json.set", "doc", "$", test}); + auto dump = Run({"dump", "doc"}); + Run({"del", "doc"}); + Run({"restore", "doc", "0", facade::ToSV(dump.GetBuf())}); + auto res = Run({"json.get", "doc"}); + CHECK_EQ(res, test); + } +} + } // namespace dfly From cb2926ee9e39d79b506239b5eaba3975dff96f39 Mon Sep 17 00:00:00 2001 From: Vladislav Oleshko Date: Sat, 14 Jan 2023 23:51:59 +0300 Subject: [PATCH 2/2] fix(tests): Use assert Signed-off-by: Vladislav Oleshko --- src/server/rdb_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/rdb_test.cc b/src/server/rdb_test.cc index 6d0aedbf100f..b0daf792aba3 100644 --- a/src/server/rdb_test.cc +++ b/src/server/rdb_test.cc @@ -330,7 +330,7 @@ TEST_F(RdbTest, JsonTest) { Run({"del", "doc"}); Run({"restore", "doc", "0", facade::ToSV(dump.GetBuf())}); auto res = Run({"json.get", "doc"}); - CHECK_EQ(res, test); + ASSERT_EQ(res, test); } }