PragmaTwice commented on code in PR #2323:
URL: https://github.com/apache/kvrocks/pull/2323#discussion_r1609211350


##########
tests/gocase/unit/type/json/json_test.go:
##########
@@ -627,6 +627,17 @@ func TestJson(t *testing.T) {
                EqualJSON(t, `[{"a": 4, "b": 5, "nested": {"a": 6}, "c": 
null}]`, rdb.Do(ctx, "JSON.GET", "a1", "$").Val())
                EqualJSON(t, `[4]`, rdb.Do(ctx, "JSON.GET", "a1", "$.a").Val())
        })
+
+       t.Run("JSON.DEBUG MEMORY basics", func(t *testing.T) {
+               var result1 = make([]interface{}, 0)
+               result1 = append(result1, int64(4))
+               require.NoError(t, rdb.Do(ctx, "JSON.SET", "a", "$", 
`{"a":"foo", "nested": {"a": "hello"}, "nested2": {"a": 31}}`).Err())
+               require.Equal(t, rdb.Do(ctx, "JSON.DEBUG", "MEMORY", "a", 
"$.a").Val(), result1)
+               var result2 = make([]interface{}, 0)
+               result2 = append(result2, int64(4), int64(6), int64(2))
+               require.Equal(t, rdb.Do(ctx, "JSON.DEBUG", "MEMORY", "a", 
"$..a").Val(), result2)
+               require.ErrorIs(t, rdb.Do(ctx, "JSON.DEBUG", "MEMORY", 
"not_exists", "$").Err(), redis.Nil)

Review Comment:
   Could you add more test cases? e.g. for a valid `$`, or a 
number/array/object, or a non-existent path.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to