1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-26 19:21:03 +03:00

Add WithTimeout

This commit is contained in:
Vladimir Mihailenco
2020-02-02 14:59:27 +02:00
parent 2df96f7ef0
commit d2e52839ee
4 changed files with 62 additions and 18 deletions

View File

@ -59,6 +59,10 @@ var _ = Describe("Client", func() {
client.Close()
})
It("should Stringer", func() {
Expect(client.String()).To(Equal("Redis<:6380 db:15>"))
})
It("supports WithContext", func() {
c, cancel := context.WithCancel(context.Background())
cancel()
@ -67,8 +71,15 @@ var _ = Describe("Client", func() {
Expect(err).To(MatchError("context canceled"))
})
It("should Stringer", func() {
Expect(client.String()).To(Equal("Redis<:6380 db:15>"))
It("supports WithTimeout", func() {
err := client.ClientPause(time.Second).Err()
Expect(err).NotTo(HaveOccurred())
err = client.WithTimeout(10 * time.Millisecond).Ping().Err()
Expect(err).To(HaveOccurred())
err = client.Ping().Err()
Expect(err).NotTo(HaveOccurred())
})
It("should ping", func() {