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:
@ -15,7 +15,7 @@ var _ = Describe("Cmd", func() {
|
||||
|
||||
BeforeEach(func() {
|
||||
client = redis.NewClient(redisOptions())
|
||||
Expect(client.FlushDB().Err()).NotTo(HaveOccurred())
|
||||
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
@ -23,19 +23,19 @@ var _ = Describe("Cmd", func() {
|
||||
})
|
||||
|
||||
It("implements Stringer", func() {
|
||||
set := client.Set("foo", "bar", 0)
|
||||
set := client.Set(ctx, "foo", "bar", 0)
|
||||
Expect(set.String()).To(Equal("set foo bar: OK"))
|
||||
|
||||
get := client.Get("foo")
|
||||
get := client.Get(ctx, "foo")
|
||||
Expect(get.String()).To(Equal("get foo: bar"))
|
||||
})
|
||||
|
||||
It("has val/err", func() {
|
||||
set := client.Set("key", "hello", 0)
|
||||
set := client.Set(ctx, "key", "hello", 0)
|
||||
Expect(set.Err()).NotTo(HaveOccurred())
|
||||
Expect(set.Val()).To(Equal("OK"))
|
||||
|
||||
get := client.Get("key")
|
||||
get := client.Get(ctx, "key")
|
||||
Expect(get.Err()).NotTo(HaveOccurred())
|
||||
Expect(get.Val()).To(Equal("hello"))
|
||||
|
||||
@ -44,18 +44,18 @@ var _ = Describe("Cmd", func() {
|
||||
})
|
||||
|
||||
It("has helpers", func() {
|
||||
set := client.Set("key", "10", 0)
|
||||
set := client.Set(ctx, "key", "10", 0)
|
||||
Expect(set.Err()).NotTo(HaveOccurred())
|
||||
|
||||
n, err := client.Get("key").Int64()
|
||||
n, err := client.Get(ctx, "key").Int64()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(n).To(Equal(int64(10)))
|
||||
|
||||
un, err := client.Get("key").Uint64()
|
||||
un, err := client.Get(ctx, "key").Uint64()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(un).To(Equal(uint64(10)))
|
||||
|
||||
f, err := client.Get("key").Float64()
|
||||
f, err := client.Get(ctx, "key").Float64()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(f).To(Equal(float64(10)))
|
||||
})
|
||||
@ -63,10 +63,10 @@ var _ = Describe("Cmd", func() {
|
||||
It("supports float32", func() {
|
||||
f := float32(66.97)
|
||||
|
||||
err := client.Set("float_key", f, 0).Err()
|
||||
err := client.Set(ctx, "float_key", f, 0).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
val, err := client.Get("float_key").Float32()
|
||||
val, err := client.Get(ctx, "float_key").Float32()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(val).To(Equal(f))
|
||||
})
|
||||
@ -74,14 +74,14 @@ var _ = Describe("Cmd", func() {
|
||||
It("supports time.Time", func() {
|
||||
tm := time.Date(2019, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
err := client.Set("time_key", tm, 0).Err()
|
||||
err := client.Set(ctx, "time_key", tm, 0).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
s, err := client.Get("time_key").Result()
|
||||
s, err := client.Get(ctx, "time_key").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(s).To(Equal("2019-01-01T00:00:00Z"))
|
||||
|
||||
tm2, err := client.Get("time_key").Time()
|
||||
tm2, err := client.Get(ctx, "time_key").Time()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(tm2).To(BeTemporally("==", tm))
|
||||
})
|
||||
|
Reference in New Issue
Block a user