2
0

Fix flickering test

This commit is contained in:
Jack Christensen
2019-04-24 16:49:52 -05:00
parent 23a91ebc90
commit 1e3961bd0e
+6 -1
View File
@@ -1289,7 +1289,12 @@ func TestConnCancelRequest(t *testing.T) {
require.NoError(t, err)
defer closeConn(t, pgConn)
multiResult := pgConn.Exec(context.Background(), "select 'Hello, world', pg_sleep(5)")
multiResult := pgConn.Exec(context.Background(), "select 'Hello, world', pg_sleep(2)")
// This test flickers without the Sleep. It appears that since Exec only sends the query and returns without awaiting a
// response that the CancelRequest can race it and be received before the query is running and cancellable. So wait a
// few milliseconds.
time.Sleep(50 * time.Millisecond)
err = pgConn.CancelRequest(context.Background())
require.NoError(t, err)