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

multi: fix recovering from bad connection.

This commit is contained in:
Vladimir Mihailenco
2015-11-14 14:44:16 +02:00
parent 470271c81e
commit ade3425870
12 changed files with 108 additions and 51 deletions

View File

@ -119,4 +119,30 @@ var _ = Describe("Multi", func() {
Expect(get.Val()).To(Equal("20000"))
})
It("should recover from bad connection", func() {
// Put bad connection in the pool.
cn, _, err := client.Pool().Get()
Expect(err).NotTo(HaveOccurred())
cn.SetNetConn(&badConn{})
err = client.Pool().Put(cn)
Expect(err).NotTo(HaveOccurred())
multi := client.Multi()
defer func() {
Expect(multi.Close()).NotTo(HaveOccurred())
}()
_, err = multi.Exec(func() error {
multi.Ping()
return nil
})
Expect(err).To(MatchError("bad connection"))
_, err = multi.Exec(func() error {
multi.Ping()
return nil
})
Expect(err).NotTo(HaveOccurred())
})
})