summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-redis/redis/iterator_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-04-16 05:37:14 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-04-16 08:37:14 -0400
commit6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch)
tree3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/github.com/go-redis/redis/iterator_test.go
parentbf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff)
downloadchat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/github.com/go-redis/redis/iterator_test.go')
-rw-r--r--vendor/github.com/go-redis/redis/iterator_test.go136
1 files changed, 0 insertions, 136 deletions
diff --git a/vendor/github.com/go-redis/redis/iterator_test.go b/vendor/github.com/go-redis/redis/iterator_test.go
deleted file mode 100644
index a2e623813..000000000
--- a/vendor/github.com/go-redis/redis/iterator_test.go
+++ /dev/null
@@ -1,136 +0,0 @@
-package redis_test
-
-import (
- "fmt"
-
- "github.com/go-redis/redis"
-
- . "github.com/onsi/ginkgo"
- . "github.com/onsi/gomega"
-)
-
-var _ = Describe("ScanIterator", func() {
- var client *redis.Client
-
- var seed = func(n int) error {
- pipe := client.Pipeline()
- for i := 1; i <= n; i++ {
- pipe.Set(fmt.Sprintf("K%02d", i), "x", 0).Err()
- }
- _, err := pipe.Exec()
- 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()
- for i := 1; i <= n; i++ {
- pipe.HSet(hashKey, fmt.Sprintf("K%02d", i), "x").Err()
- }
- _, err := pipe.Exec()
- return err
- }
-
- BeforeEach(func() {
- client = redis.NewClient(redisOptions())
- Expect(client.FlushDB().Err()).NotTo(HaveOccurred())
- })
-
- AfterEach(func() {
- Expect(client.Close()).NotTo(HaveOccurred())
- })
-
- It("should scan across empty DBs", func() {
- iter := client.Scan(0, "", 10).Iterator()
- Expect(iter.Next()).To(BeFalse())
- Expect(iter.Err()).NotTo(HaveOccurred())
- })
-
- It("should scan across one page", func() {
- Expect(seed(7)).NotTo(HaveOccurred())
-
- var vals []string
- iter := client.Scan(0, "", 0).Iterator()
- for iter.Next() {
- vals = append(vals, iter.Val())
- }
- Expect(iter.Err()).NotTo(HaveOccurred())
- Expect(vals).To(ConsistOf([]string{"K01", "K02", "K03", "K04", "K05", "K06", "K07"}))
- })
-
- It("should scan across multiple pages", func() {
- Expect(seed(71)).NotTo(HaveOccurred())
-
- var vals []string
- iter := client.Scan(0, "", 10).Iterator()
- for iter.Next() {
- vals = append(vals, iter.Val())
- }
- Expect(iter.Err()).NotTo(HaveOccurred())
- Expect(vals).To(HaveLen(71))
- Expect(vals).To(ContainElement("K01"))
- Expect(vals).To(ContainElement("K71"))
- })
-
- It("should hscan across multiple pages", func() {
- Expect(hashSeed(71)).NotTo(HaveOccurred())
-
- var vals []string
- iter := client.HScan(hashKey, 0, "", 10).Iterator()
- for iter.Next() {
- vals = append(vals, iter.Val())
- }
- Expect(iter.Err()).NotTo(HaveOccurred())
- Expect(vals).To(HaveLen(71 * 2))
- Expect(vals).To(ContainElement("K01"))
- Expect(vals).To(ContainElement("K71"))
- })
-
- It("should scan to page borders", func() {
- Expect(seed(20)).NotTo(HaveOccurred())
-
- var vals []string
- iter := client.Scan(0, "", 10).Iterator()
- for iter.Next() {
- vals = append(vals, iter.Val())
- }
- Expect(iter.Err()).NotTo(HaveOccurred())
- Expect(vals).To(HaveLen(20))
- })
-
- It("should scan with match", func() {
- Expect(seed(33)).NotTo(HaveOccurred())
-
- var vals []string
- iter := client.Scan(0, "K*2*", 10).Iterator()
- for iter.Next() {
- vals = append(vals, iter.Val())
- }
- Expect(iter.Err()).NotTo(HaveOccurred())
- 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))
- })
-})