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

Simplify PubSub API

This commit is contained in:
Vladimir Mihailenco
2017-04-11 16:53:55 +03:00
parent 3b1a641e2c
commit 8d52a95269
7 changed files with 41 additions and 78 deletions

View File

@ -58,11 +58,10 @@ var _ = Describe("Client", func() {
})
It("should close pubsub without closing the client", func() {
pubsub, err := client.Subscribe()
Expect(err).NotTo(HaveOccurred())
pubsub := client.Subscribe()
Expect(pubsub.Close()).NotTo(HaveOccurred())
_, err = pubsub.Receive()
_, err := pubsub.Receive()
Expect(err).To(MatchError("redis: client is closed"))
Expect(client.Ping().Err()).NotTo(HaveOccurred())
})
@ -92,11 +91,10 @@ var _ = Describe("Client", func() {
})
It("should close pubsub when client is closed", func() {
pubsub, err := client.Subscribe()
Expect(err).NotTo(HaveOccurred())
pubsub := client.Subscribe()
Expect(client.Close()).NotTo(HaveOccurred())
_, err = pubsub.Receive()
_, err := pubsub.Receive()
Expect(err).To(HaveOccurred())
Expect(pubsub.Close()).NotTo(HaveOccurred())
@ -242,7 +240,8 @@ var _ = Describe("Client timeout", func() {
})
It("Subscribe timeouts", func() {
_, err := client.Subscribe("_")
pubsub := client.Subscribe()
err := pubsub.Subscribe("_")
Expect(err).To(HaveOccurred())
Expect(err.(net.Error).Timeout()).To(BeTrue())
})