mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Set conn.UsedAt when connection is created. Fixes #263.
This commit is contained in:
@ -173,18 +173,23 @@ var _ = Describe("Client", func() {
|
||||
It("should maintain conn.UsedAt", func() {
|
||||
cn, _, err := client.Pool().Get()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(cn.UsedAt).To(BeZero())
|
||||
Expect(cn.UsedAt).NotTo(BeZero())
|
||||
createdAt := cn.UsedAt
|
||||
|
||||
future := time.Now().Add(time.Hour)
|
||||
redis.SetTime(future)
|
||||
defer redis.RestoreTime()
|
||||
|
||||
err = client.Pool().Put(cn)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(cn.UsedAt).To(BeZero())
|
||||
Expect(cn.UsedAt.Equal(createdAt)).To(BeTrue())
|
||||
|
||||
err = client.Ping().Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
cn = client.Pool().First()
|
||||
Expect(cn).NotTo(BeNil())
|
||||
Expect(cn.UsedAt).To(BeTemporally("~", time.Now()))
|
||||
Expect(cn.UsedAt.Equal(future)).To(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user