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

Function TestConnExecPreparedPrecanceled

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

Source from the content-addressed store, hash-verified

1575}
1576
1577func TestConnExecPreparedPrecanceled(t *testing.T) {
1578 t.Parallel()
1579
1580 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
1581 defer cancel()
1582
1583 pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
1584 require.NoError(t, err)
1585 defer closeConn(t, pgConn)
1586
1587 _, err = pgConn.Prepare(ctx, "ps1", "select current_database(), pg_sleep(1)", nil)
1588 require.NoError(t, err)
1589
1590 cancel()
1591 result := pgConn.ExecPrepared(ctx, "ps1", nil, nil, nil).Read()
1592 require.Error(t, result.Err)
1593 assert.True(t, errors.Is(result.Err, context.Canceled))
1594 assert.True(t, pgconn.SafeToRetry(result.Err))
1595
1596 ensureConnValid(t, pgConn)
1597}
1598
1599func TestConnExecPreparedEmptySQL(t *testing.T) {
1600 t.Parallel()

Callers

nothing calls this directly

Calls 8

ConnectFunction · 0.92
SafeToRetryFunction · 0.92
closeConnFunction · 0.70
ensureConnValidFunction · 0.70
PrepareMethod · 0.65
ReadMethod · 0.45
ExecPreparedMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected