1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Improve ReceiveMessage.

This commit is contained in:
Vladimir Mihailenco
2015-12-02 15:40:44 +02:00
parent 5efe0cceb6
commit 42141f11d1
4 changed files with 46 additions and 31 deletions

View File

@ -260,9 +260,9 @@ var _ = Describe("PubSub", func() {
Expect(err).NotTo(HaveOccurred())
defer pubsub.Close()
cn, _, err := pubsub.Pool().Get()
cn1, _, err := pubsub.Pool().Get()
Expect(err).NotTo(HaveOccurred())
cn.SetNetConn(&badConn{
cn1.SetNetConn(&badConn{
readErr: errTimeout,
writeErr: errTimeout,
})
@ -286,7 +286,7 @@ var _ = Describe("PubSub", func() {
wg.Wait()
})
It("should not panic on Close", func() {
It("should return on Close", func() {
pubsub, err := client.Subscribe("mychannel")
Expect(err).NotTo(HaveOccurred())
defer pubsub.Close()
@ -297,13 +297,20 @@ var _ = Describe("PubSub", func() {
defer GinkgoRecover()
wg.Done()
_, err := pubsub.ReceiveMessage()
Expect(err).To(MatchError("redis: client is closed"))
wg.Done()
}()
wg.Wait()
wg.Add(1)
err = pubsub.Close()
Expect(err).NotTo(HaveOccurred())
wg.Wait()
})
})