diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-07-31 08:15:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-31 08:15:23 -0700 |
commit | 09b49c26ddfdb20ced61e7dfd4192e750ce40449 (patch) | |
tree | 1288d069cc8a199b8eb3b858935dffd377ee3d2d /vendor/github.com/go-redis/redis/pipeline_test.go | |
parent | 6f4e38d129ffaf469d40fc8596d3957ee94d21e9 (diff) | |
download | chat-09b49c26ddfdb20ced61e7dfd4192e750ce40449.tar.gz chat-09b49c26ddfdb20ced61e7dfd4192e750ce40449.tar.bz2 chat-09b49c26ddfdb20ced61e7dfd4192e750ce40449.zip |
PLT-5308 Caching layer part 2 (#6973)
* Adding Reaction store cache layer example
* Implementing reaction store in new caching system.
* Redis for reaction store
* Adding redis library
* Adding invalidation for DeleteAllWithEmojiName and other minor enhancements
Diffstat (limited to 'vendor/github.com/go-redis/redis/pipeline_test.go')
-rw-r--r-- | vendor/github.com/go-redis/redis/pipeline_test.go | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/vendor/github.com/go-redis/redis/pipeline_test.go b/vendor/github.com/go-redis/redis/pipeline_test.go new file mode 100644 index 000000000..11896c6bb --- /dev/null +++ b/vendor/github.com/go-redis/redis/pipeline_test.go @@ -0,0 +1,80 @@ +package redis_test + +import ( + "github.com/go-redis/redis" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("pipelining", func() { + var client *redis.Client + var pipe *redis.Pipeline + + BeforeEach(func() { + client = redis.NewClient(redisOptions()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) + }) + + AfterEach(func() { + Expect(client.Close()).NotTo(HaveOccurred()) + }) + + It("supports block style", func() { + var get *redis.StringCmd + cmds, err := client.Pipelined(func(pipe redis.Pipeliner) error { + get = pipe.Get("foo") + return nil + }) + Expect(err).To(Equal(redis.Nil)) + Expect(cmds).To(HaveLen(1)) + Expect(cmds[0]).To(Equal(get)) + Expect(get.Err()).To(Equal(redis.Nil)) + Expect(get.Val()).To(Equal("")) + }) + + assertPipeline := func() { + It("returns no errors when there are no commands", func() { + _, err := pipe.Exec() + Expect(err).NotTo(HaveOccurred()) + }) + + It("discards queued commands", func() { + pipe.Get("key") + pipe.Discard() + cmds, err := pipe.Exec() + Expect(err).NotTo(HaveOccurred()) + Expect(cmds).To(BeNil()) + }) + + It("handles val/err", func() { + err := client.Set("key", "value", 0).Err() + Expect(err).NotTo(HaveOccurred()) + + get := pipe.Get("key") + cmds, err := pipe.Exec() + Expect(err).NotTo(HaveOccurred()) + Expect(cmds).To(HaveLen(1)) + + val, err := get.Result() + Expect(err).NotTo(HaveOccurred()) + Expect(val).To(Equal("value")) + }) + } + + Describe("Pipeline", func() { + BeforeEach(func() { + pipe = client.Pipeline().(*redis.Pipeline) + }) + + assertPipeline() + }) + + Describe("TxPipeline", func() { + BeforeEach(func() { + pipe = client.TxPipeline().(*redis.Pipeline) + }) + + assertPipeline() + }) +}) |