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

Function TestConnExecContextPrecanceled

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

Source from the content-addressed store, hash-verified

1194}
1195
1196func TestConnExecContextPrecanceled(t *testing.T) {
1197 t.Parallel()
1198
1199 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
1200 defer cancel()
1201
1202 pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
1203 require.NoError(t, err)
1204 defer closeConn(t, pgConn)
1205
1206 cancel()
1207 _, err = pgConn.Exec(ctx, "select 'Hello, world'").ReadAll()
1208 assert.Error(t, err)
1209 assert.True(t, errors.Is(err, context.Canceled))
1210 assert.True(t, pgconn.SafeToRetry(err))
1211
1212 ensureConnValid(t, pgConn)
1213}
1214
1215func TestConnExecParams(t *testing.T) {
1216 t.Parallel()

Callers

nothing calls this directly

Calls 7

ConnectFunction · 0.92
SafeToRetryFunction · 0.92
ReadAllMethod · 0.80
closeConnFunction · 0.70
ensureConnValidFunction · 0.70
ExecMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected