Skip to content

Commit

Permalink
Add test for MGet/struct scan
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Feb 3, 2021
1 parent bd234b9 commit f8a546b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,22 @@ var _ = Describe("Commands", func() {
Expect(mGet.Val()).To(Equal([]interface{}{"hello1", "hello2", nil}))
})

It("should scan Mget", func() {
err := client.MSet(ctx, "key1", "hello1", "key2", 123).Err()
Expect(err).NotTo(HaveOccurred())

res := client.MGet(ctx, "key1", "key2", "_")
Expect(res.Err()).NotTo(HaveOccurred())

type data struct {
Key1 string `redis:"key1"`
Key2 int `redis:"key2"`
}
var d data
Expect(res.Scan(&d)).NotTo(HaveOccurred())
Expect(d).To(Equal(data{Key1: "hello1", Key2: 123}))
})

It("should MSetNX", func() {
mSetNX := client.MSetNX(ctx, "key1", "hello1", "key2", "hello2")
Expect(mSetNX.Err()).NotTo(HaveOccurred())
Expand Down

0 comments on commit f8a546b

Please sign in to comment.