From f8a546b4820de9e52fe0d244e24dca155688abef Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Wed, 3 Feb 2021 17:10:01 +0530 Subject: [PATCH] Add test for MGet/struct scan --- commands_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/commands_test.go b/commands_test.go index 19af05f..a73f4f8 100644 --- a/commands_test.go +++ b/commands_test.go @@ -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())