1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Add ctx as first arg

This commit is contained in:
Vladimir Mihailenco
2020-03-11 16:26:42 +02:00
parent 64bb0b7f3a
commit f5593121e0
36 changed files with 3200 additions and 2970 deletions

View File

@ -13,7 +13,7 @@ var _ = Describe("pipelining", func() {
BeforeEach(func() {
client = redis.NewClient(redisOptions())
Expect(client.FlushDB().Err()).NotTo(HaveOccurred())
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
})
AfterEach(func() {
@ -22,8 +22,8 @@ var _ = Describe("pipelining", func() {
It("supports block style", func() {
var get *redis.StringCmd
cmds, err := client.Pipelined(func(pipe redis.Pipeliner) error {
get = pipe.Get("foo")
cmds, err := client.Pipelined(ctx, func(pipe redis.Pipeliner) error {
get = pipe.Get(ctx, "foo")
return nil
})
Expect(err).To(Equal(redis.Nil))
@ -35,24 +35,24 @@ var _ = Describe("pipelining", func() {
assertPipeline := func() {
It("returns no errors when there are no commands", func() {
_, err := pipe.Exec()
_, err := pipe.Exec(ctx)
Expect(err).NotTo(HaveOccurred())
})
It("discards queued commands", func() {
pipe.Get("key")
pipe.Get(ctx, "key")
pipe.Discard()
cmds, err := pipe.Exec()
cmds, err := pipe.Exec(ctx)
Expect(err).NotTo(HaveOccurred())
Expect(cmds).To(BeNil())
})
It("handles val/err", func() {
err := client.Set("key", "value", 0).Err()
err := client.Set(ctx, "key", "value", 0).Err()
Expect(err).NotTo(HaveOccurred())
get := pipe.Get("key")
cmds, err := pipe.Exec()
get := pipe.Get(ctx, "key")
cmds, err := pipe.Exec(ctx)
Expect(err).NotTo(HaveOccurred())
Expect(cmds).To(HaveLen(1))
@ -62,8 +62,8 @@ var _ = Describe("pipelining", func() {
})
It("supports custom command", func() {
pipe.Do("ping")
cmds, err := pipe.Exec()
pipe.Do(ctx, "ping")
cmds, err := pipe.Exec(ctx)
Expect(err).NotTo(HaveOccurred())
Expect(cmds).To(HaveLen(1))
})