Skip to content

Commit 2b4fa17

Browse files
committed
Fix flaky TestConnPrepareContext
TestConnPrepareContext checks it receives an context.DeadlineExceeded. However, the context isn't necessarily always expired. This causes most of the test runs to fail for me, only occasionally succeeding. This change ensures the context used in the test is actually context.DeadlineExceeded. The negative duration causes the context package to return an already canceled context.
1 parent 26399a7 commit 2b4fa17

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

conn_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ func TestConnPrepareContext(t *testing.T) {
18281828
{
18291829
name: "context.WithTimeout exceeded",
18301830
ctx: func() (context.Context, context.CancelFunc) {
1831-
return context.WithTimeout(context.Background(), time.Microsecond)
1831+
return context.WithTimeout(context.Background(), -time.Minute)
18321832
},
18331833
sql: "SELECT 1",
18341834
err: context.DeadlineExceeded,

0 commit comments

Comments
 (0)