1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-14 01:21:30 +03:00

Refactor scan signature to work with Slice and StringMap cmds

This commit is contained in:
Kailash Nadh
2021-02-02 16:28:10 +05:30
parent a4144ea98e
commit f9dfc7a949
4 changed files with 74 additions and 47 deletions

View File

@ -1375,6 +1375,22 @@ var _ = Describe("Commands", func() {
Expect(m).To(Equal(map[string]string{"key1": "hello1", "key2": "hello2"}))
})
It("should scan", func() {
err := client.HMSet(ctx, "hash", "key1", "hello1", "key2", 123).Err()
Expect(err).NotTo(HaveOccurred())
res := client.HGetAll(ctx, "hash")
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 HIncrBy", func() {
hSet := client.HSet(ctx, "hash", "key", "5")
Expect(hSet.Err()).NotTo(HaveOccurred())