Skip to content

Commit 18b46a1

Browse files
committed
fix flaky test
1 parent 95af71c commit 18b46a1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/pool/conn_used_at_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestConn_UsedAtUpdatedOnRead(t *testing.T) {
2222
// Get initial usedAt time
2323
initialUsedAt := cn.UsedAt()
2424

25-
// Wait at least 50ms to ensure time difference (usedAt has ~50ms precision from cached time)
25+
// Wait 100ms to ensure time difference (usedAt has ~50ms precision from cached time)
2626
time.Sleep(100 * time.Millisecond)
2727

2828
// Simulate a read operation by calling WithReader
@@ -45,10 +45,10 @@ func TestConn_UsedAtUpdatedOnRead(t *testing.T) {
4545
initialUsedAt, updatedUsedAt)
4646
}
4747

48-
// Verify the difference is reasonable (should be around 50ms, accounting for ~50ms cache precision)
48+
// Verify the difference is reasonable (should be around 100ms, accounting for ~50ms cache precision and ~5ms sleep precision)
4949
diff := updatedUsedAt.Sub(initialUsedAt)
50-
if diff < 50*time.Millisecond || diff > 200*time.Millisecond {
51-
t.Errorf("Expected usedAt difference to be around 50ms (±50ms for cache), got %v", diff)
50+
if diff < 45*time.Millisecond || diff > 155*time.Millisecond {
51+
t.Errorf("Expected usedAt difference to be around 100ms (±50ms for cache, ±5ms for sleep), got %v", diff)
5252
}
5353
}
5454

0 commit comments

Comments
 (0)