mirror of
https://github.com/redis/go-redis.git
synced 2025-07-26 19:21:03 +03:00
Cleanup pool
This commit is contained in:
@ -145,12 +145,11 @@ var _ = Describe("Client", func() {
|
||||
})
|
||||
|
||||
// Put bad connection in the pool.
|
||||
cn, _, err := client.Pool().Get()
|
||||
cn, err := client.Pool().Get()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
cn.SetNetConn(&badConn{})
|
||||
err = client.Pool().Put(cn)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
client.Pool().Put(cn)
|
||||
|
||||
err = client.Ping().Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -184,19 +183,18 @@ var _ = Describe("Client", func() {
|
||||
})
|
||||
|
||||
It("should update conn.UsedAt on read/write", func() {
|
||||
cn, _, err := client.Pool().Get()
|
||||
cn, err := client.Pool().Get()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(cn.UsedAt).NotTo(BeZero())
|
||||
createdAt := cn.UsedAt()
|
||||
|
||||
err = client.Pool().Put(cn)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
client.Pool().Put(cn)
|
||||
Expect(cn.UsedAt().Equal(createdAt)).To(BeTrue())
|
||||
|
||||
err = client.Ping().Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
cn, _, err = client.Pool().Get()
|
||||
cn, err = client.Pool().Get()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(cn).NotTo(BeNil())
|
||||
Expect(cn.UsedAt().After(createdAt)).To(BeTrue())
|
||||
|
Reference in New Issue
Block a user