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

Function TestExecContextWithoutCancelation

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

Source from the content-addressed store, hash-verified

314}
315
316func TestExecContextWithoutCancelation(t *testing.T) {
317 t.Parallel()
318
319 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
320 defer cancel()
321
322 pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
323 ctx, cancelFunc := context.WithCancel(ctx)
324 defer cancelFunc()
325
326 commandTag, err := conn.Exec(ctx, "create temporary table foo(id integer primary key);")
327 if err != nil {
328 t.Fatal(err)
329 }
330 if commandTag.String() != "CREATE TABLE" {
331 t.Fatalf("Unexpected results from Exec: %v", commandTag)
332 }
333 assert.False(t, pgconn.SafeToRetry(err))
334 })
335}
336
337func TestExecContextFailureWithoutCancelation(t *testing.T) {
338 t.Parallel()

Callers

nothing calls this directly

Calls 4

RunWithQueryExecModesFunction · 0.92
SafeToRetryFunction · 0.92
ExecMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected