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

Function TestExecContextFailureWithoutCancelation

conn_test.go:337–360  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

335}
336
337func TestExecContextFailureWithoutCancelation(t *testing.T) {
338 t.Parallel()
339
340 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
341 defer cancel()
342
343 pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
344 ctx, cancelFunc := context.WithCancel(ctx)
345 defer cancelFunc()
346
347 _, err := conn.Exec(ctx, "selct;")
348 if err == nil {
349 t.Fatal("Expected SQL syntax error")
350 }
351 assert.False(t, pgconn.SafeToRetry(err))
352
353 rows, _ := conn.Query(context.Background(), "select 1")
354 rows.Close()
355 if rows.Err() != nil {
356 t.Fatalf("ExecEx failure appears to have broken connection: %v", rows.Err())
357 }
358 assert.False(t, pgconn.SafeToRetry(err))
359 })
360}
361
362func TestExecContextFailureWithoutCancelationWithArguments(t *testing.T) {
363 t.Parallel()

Callers

nothing calls this directly

Calls 6

RunWithQueryExecModesFunction · 0.92
SafeToRetryFunction · 0.92
ExecMethod · 0.65
QueryMethod · 0.65
CloseMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected