1
0
mirror of https://github.com/redis/go-redis.git synced 2025-09-07 07:47:24 +03:00

Ensure that JSON.GET returns Nil response

Updated JSONCmd.readReply to return redis.Nil if no results
Added a doc line for Val() and Expanded() methods of JSONCmd
Added a test case for non existent keys in json_test.go
This commit is contained in:
Nic Gibson
2024-04-16 12:13:13 +01:00
parent f7f34feddf
commit 215d53e021
2 changed files with 14 additions and 3 deletions

View File

@@ -123,9 +123,14 @@ var _ = Describe("JSON Commands", Label("json"), func() {
Expect(err).NotTo(HaveOccurred())
Expect(resGet).To(Equal("[[10,20,30,40],[5,10,20,30]]"))
_, err = client.JSONGet(ctx, "this-key-does-not-exist", "$").Result()
Expect(err).To(HaveOccurred())
Expect(err).To(BeIdenticalTo(redis.Nil))
resArr, err := client.JSONArrIndex(ctx, "doc1", "$.store.book[?(@.price<10)].size", 20).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resArr).To(Equal([]int64{1, 2}))
})
It("should JSONArrInsert", Label("json.arrinsert", "json"), func() {