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

fix iterator across empty pages

This commit is contained in:
vkd
2016-09-08 16:07:49 +03:00
parent 49f197e6d1
commit 76c33da3ee
2 changed files with 45 additions and 17 deletions

View File

@ -21,6 +21,18 @@ var _ = Describe("ScanIterator", func() {
return err
}
var extraSeed = func(n int, m int) error {
pipe := client.Pipeline()
for i := 1; i <= m; i++ {
pipe.Set(fmt.Sprintf("A%02d", i), "x", 0).Err()
}
for i := 1; i <= n; i++ {
pipe.Set(fmt.Sprintf("K%02d", i), "x", 0).Err()
}
_, err := pipe.Exec()
return err
}
var hashKey = "K_HASHTEST"
var hashSeed = func(n int) error {
pipe := client.Pipeline()
@ -110,4 +122,15 @@ var _ = Describe("ScanIterator", func() {
Expect(vals).To(HaveLen(13))
})
It("should scan with match across empty pages", func() {
Expect(extraSeed(2, 10)).NotTo(HaveOccurred())
var vals []string
iter := client.Scan(0, "K*", 1).Iterator()
for iter.Next() {
vals = append(vals, iter.Val())
}
Expect(iter.Err()).NotTo(HaveOccurred())
Expect(vals).To(HaveLen(2))
})
})