Skip to content

Commit 35a602c

Browse files
feat(json_family): Copy json_test.py::test_reset_key_to_string to json_family_test (#5324)
Signed-off-by: Stepan Bagritsevich <[email protected]>
1 parent dd44c89 commit 35a602c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/server/json_family_test.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,4 +3128,31 @@ TEST_F(JsonFamilyTest, JsonCommandsWorkingWithOtherTypesBug) {
31283128
EXPECT_THAT(resp, "value");
31293129
}
31303130

3131+
TEST_F(JsonFamilyTest, ResetStringKeyWithSetGet) {
3132+
auto resp = Run({"JSON.SET", "key", "$", R"({"a":"b"})"});
3133+
ASSERT_THAT(resp, "OK");
3134+
3135+
resp = Run({"JSON.GET", "key"});
3136+
EXPECT_THAT(resp, R"({"a":"b"})");
3137+
3138+
// Resetting the key with a string value
3139+
resp = Run({"SET", "key", R"({"a":"b"})"});
3140+
ASSERT_THAT(resp, "OK");
3141+
3142+
resp = Run({"GET", "key"});
3143+
EXPECT_THAT(resp, R"({"a":"b"})");
3144+
3145+
// JSON.GET should still work after resetting the key with a string value
3146+
resp = Run({"JSON.GET", "key"});
3147+
EXPECT_THAT(resp, R"({"a":"b"})");
3148+
3149+
// Resetting the key again with JSON.SET
3150+
// This should not cause any issues
3151+
resp = Run({"JSON.SET", "key", "$", R"({"a":"b"})"});
3152+
ASSERT_THAT(resp, "OK");
3153+
3154+
resp = Run({"JSON.GET", "key"});
3155+
EXPECT_THAT(resp, R"({"a":"b"})");
3156+
}
3157+
31313158
} // namespace dfly

0 commit comments

Comments
 (0)