MCPcopy
hub / github.com/jackc/pgx / TestConnExecParamsPrecanceled

Function TestConnExecParamsPrecanceled

pgconn/pgconn_test.go:1359–1376  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1357}
1358
1359func TestConnExecParamsPrecanceled(t *testing.T) {
1360 t.Parallel()
1361
1362 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
1363 defer cancel()
1364
1365 pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
1366 require.NoError(t, err)
1367 defer closeConn(t, pgConn)
1368
1369 cancel()
1370 result := pgConn.ExecParams(ctx, "select $1::text", [][]byte{[]byte("Hello, world")}, nil, nil, nil).Read()
1371 require.Error(t, result.Err)
1372 assert.True(t, errors.Is(result.Err, context.Canceled))
1373 assert.True(t, pgconn.SafeToRetry(result.Err))
1374
1375 ensureConnValid(t, pgConn)
1376}
1377
1378func TestConnExecParamsEmptySQL(t *testing.T) {
1379 t.Parallel()

Callers

nothing calls this directly

Calls 7

ConnectFunction · 0.92
SafeToRetryFunction · 0.92
closeConnFunction · 0.70
ensureConnValidFunction · 0.70
ReadMethod · 0.45
ExecParamsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected