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

@ -27,7 +27,7 @@ var _ = Describe("pool", func() {
It("respects max size", func() {
perform(1000, func(id int) {
val, err := client.Ping().Result()
val, err := client.Ping(ctx).Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
})
@ -42,9 +42,9 @@ var _ = Describe("pool", func() {
perform(1000, func(id int) {
var ping *redis.StatusCmd
err := client.Watch(func(tx *redis.Tx) error {
cmds, err := tx.Pipelined(func(pipe redis.Pipeliner) error {
ping = pipe.Ping()
err := client.Watch(ctx, func(tx *redis.Tx) error {
cmds, err := tx.Pipelined(ctx, func(pipe redis.Pipeliner) error {
ping = pipe.Ping(ctx)
return nil
})
Expect(err).NotTo(HaveOccurred())
@ -66,8 +66,8 @@ var _ = Describe("pool", func() {
It("respects max size on pipelines", func() {
perform(1000, func(id int) {
pipe := client.Pipeline()
ping := pipe.Ping()
cmds, err := pipe.Exec()
ping := pipe.Ping(ctx)
cmds, err := pipe.Exec(ctx)
Expect(err).NotTo(HaveOccurred())
Expect(cmds).To(HaveLen(1))
Expect(ping.Err()).NotTo(HaveOccurred())
@ -87,10 +87,10 @@ var _ = Describe("pool", func() {
cn.SetNetConn(&badConn{})
client.Pool().Put(cn)
err = client.Ping().Err()
err = client.Ping(ctx).Err()
Expect(err).To(MatchError("bad connection"))
val, err := client.Ping().Result()
val, err := client.Ping(ctx).Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
@ -106,7 +106,7 @@ var _ = Describe("pool", func() {
It("reuses connections", func() {
for i := 0; i < 100; i++ {
val, err := client.Ping().Result()
val, err := client.Ping(ctx).Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
}
@ -122,7 +122,7 @@ var _ = Describe("pool", func() {
})
It("removes idle connections", func() {
err := client.Ping().Err()
err := client.Ping(ctx).Err()
Expect(err).NotTo(HaveOccurred())
stats := client.PoolStats()