Add test for MGet/struct scan

This commit is contained in:
Kailash Nadh 2021-02-03 17:10:01 +05:30
parent bd234b91fe
commit f8a546b482
1 changed files with 16 additions and 0 deletions

View File

@ -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())