Use context timeouts in more tests
Tests should timeout in a reasonable time if something is stuck. In particular this is important when testing deadlock conditions such as can occur with the copy protocol if both the client and the server are blocked writing until the other side does a read.
This commit is contained in:
+8
-2
@@ -220,7 +220,10 @@ func TestConnQueryValuesWithUnregisteredOID(t *testing.T) {
|
||||
func TestConnQueryArgsAndScanWithUnregisteredOID(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
tx, err := conn.Begin(ctx)
|
||||
require.NoError(t, err)
|
||||
defer tx.Rollback(ctx)
|
||||
@@ -1943,7 +1946,10 @@ func TestQueryErrorWithDisabledStatementCache(t *testing.T) {
|
||||
func TestQueryWithQueryRewriter(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
qr := testQueryRewriter{sql: "select $1::int", args: []any{42}}
|
||||
rows, err := conn.Query(ctx, "should be replaced", &qr)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user