mirror of https://github.com/jackc/pgx.git
Fix broken test
parent
bf1edc77d7
commit
7d04dc5caa
|
@ -1849,13 +1849,14 @@ func TestConnCancelRequest(t *testing.T) {
|
||||||
|
|
||||||
multiResult := pgConn.Exec(context.Background(), "select 'Hello, world', pg_sleep(2)")
|
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
|
go func() {
|
||||||
// response that the CancelRequest can race it and be received before the query is running and cancellable. So wait a
|
// The query is actually sent when multiResult.NextResult() is called. So wait to ensure it is sent.
|
||||||
// few milliseconds.
|
// Once Flush is available this could use that instead.
|
||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
|
||||||
err = pgConn.CancelRequest(context.Background())
|
err = pgConn.CancelRequest(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
for multiResult.NextResult() {
|
for multiResult.NextResult() {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue