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

fix test error

Signed-off-by: monkey <golang@88.com>
This commit is contained in:
monkey
2021-03-12 19:06:11 +08:00
parent 250f81bf06
commit af3827aeab
5 changed files with 46 additions and 6 deletions

View File

@ -243,13 +243,17 @@ var _ = Describe("Client", func() {
cn, err := client.Pool().Get(context.Background())
Expect(err).NotTo(HaveOccurred())
Expect(cn.UsedAt).NotTo(BeZero())
// set cn.SetUsedAt(time) or time.Sleep(>1*time.Second)
// simulate the last time Conn was used
// time.Sleep() is not the standard sleep time
// link: https://go-review.googlesource.com/c/go/+/232298
cn.SetUsedAt(time.Now().Add(-1 * time.Second))
createdAt := cn.UsedAt()
client.Pool().Put(ctx, cn)
Expect(cn.UsedAt().Equal(createdAt)).To(BeTrue())
time.Sleep(time.Second)
err = client.Ping(ctx).Err()
Expect(err).NotTo(HaveOccurred())