mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
Allow scanning redis values into pointer fields (#2787)
* Allow scanning redis values into pointer fields * Formatting --------- Co-authored-by: Ilia Personal <iliapersonal@Ilyas-MBP.station> Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
This commit is contained in:
11
json_test.go
11
json_test.go
@ -5,6 +5,7 @@ import (
|
||||
|
||||
. "github.com/bsm/ginkgo/v2"
|
||||
. "github.com/bsm/gomega"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
@ -13,7 +14,6 @@ type JSONGetTestStruct struct {
|
||||
}
|
||||
|
||||
var _ = Describe("JSON Commands", Label("json"), func() {
|
||||
|
||||
ctx := context.TODO()
|
||||
var client *redis.Client
|
||||
|
||||
@ -27,7 +27,6 @@ var _ = Describe("JSON Commands", Label("json"), func() {
|
||||
})
|
||||
|
||||
Describe("arrays", Label("arrays"), func() {
|
||||
|
||||
It("should JSONArrAppend", Label("json.arrappend", "json"), func() {
|
||||
cmd1 := client.JSONSet(ctx, "append2", "$", `{"a": [10], "b": {"a": [12, 13]}}`)
|
||||
Expect(cmd1.Err()).NotTo(HaveOccurred())
|
||||
@ -76,7 +75,6 @@ var _ = Describe("JSON Commands", Label("json"), func() {
|
||||
res, err = client.JSONArrIndexWithArgs(ctx, "index2", "$", &redis.JSONArrIndexArgs{Stop: &stop}, 4).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(res[0]).To(Equal(int64(-1)))
|
||||
|
||||
})
|
||||
|
||||
It("should JSONArrIndex and JSONArrIndexWithArgs with $", Label("json.arrindex", "json"), func() {
|
||||
@ -235,7 +233,6 @@ var _ = Describe("JSON Commands", Label("json"), func() {
|
||||
Expect(cmd3.Err()).NotTo(HaveOccurred())
|
||||
Expect(cmd3.Val()).To(Equal("[[100,200,200]]"))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Describe("get/set", Label("getset"), func() {
|
||||
@ -257,7 +254,6 @@ var _ = Describe("JSON Commands", Label("json"), func() {
|
||||
res, err = client.JSONGetWithArgs(ctx, "get3", &redis.JSONGetArgs{Indent: "-", Newline: `~`, Space: `!`}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(res).To(Equal(`[~-{~--"a":!1,~--"b":!2~-}~]`))
|
||||
|
||||
})
|
||||
|
||||
It("should JSONMerge", Label("json.merge", "json"), func() {
|
||||
@ -330,13 +326,10 @@ var _ = Describe("JSON Commands", Label("json"), func() {
|
||||
iRes, err = client.JSONMGet(ctx, "$..a", "non_existing_doc", "non_existing_doc1").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(iRes).To(Equal([]interface{}{nil, nil}))
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Describe("Misc", Label("misc"), func() {
|
||||
|
||||
It("should JSONClear", Label("json.clear", "json"), func() {
|
||||
cmd1 := client.JSONSet(ctx, "clear1", "$", `[1]`)
|
||||
Expect(cmd1.Err()).NotTo(HaveOccurred())
|
||||
@ -460,7 +453,6 @@ var _ = Describe("JSON Commands", Label("json"), func() {
|
||||
cmd3 := client.JSONGet(ctx, "forget3", "$")
|
||||
Expect(cmd3.Err()).NotTo(HaveOccurred())
|
||||
Expect(cmd3.Val()).To(Equal(`[{"b":{"b":"annie"}}]`))
|
||||
|
||||
})
|
||||
|
||||
It("should JSONForget with $", Label("json.forget", "json"), func() {
|
||||
@ -622,7 +614,6 @@ var _ = Describe("JSON Commands", Label("json"), func() {
|
||||
cmd3, err := client.JSONGet(ctx, "strapp1", "$").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(cmd3).To(Equal(`["foobar"]`))
|
||||
|
||||
})
|
||||
|
||||
It("should JSONStrAppend and JSONStrLen with $", Label("json.strappend", "json.strlen", "json"), func() {
|
||||
|
Reference in New Issue
Block a user