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

Function TestConnDeallocate

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

Source from the content-addressed store, hash-verified

913}
914
915func TestConnDeallocate(t *testing.T) {
916 t.Parallel()
917
918 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
919 defer cancel()
920
921 pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
922 require.NoError(t, err)
923 defer closeConn(t, pgConn)
924
925 _, err = pgConn.Prepare(ctx, "ps1", "select 1", nil)
926 require.NoError(t, err)
927
928 _, err = pgConn.ExecPrepared(ctx, "ps1", nil, nil, nil).Close()
929 require.NoError(t, err)
930
931 err = pgConn.Deallocate(ctx, "ps1")
932 require.NoError(t, err)
933
934 _, err = pgConn.ExecPrepared(ctx, "ps1", nil, nil, nil).Close()
935 require.Error(t, err)
936 var pgErr *pgconn.PgError
937 require.ErrorAs(t, err, &pgErr)
938 require.Equal(t, "26000", pgErr.Code)
939
940 ensureConnValid(t, pgConn)
941}
942
943func TestConnDeallocateSucceedsInAbortedTransaction(t *testing.T) {
944 t.Parallel()

Callers

nothing calls this directly

Calls 8

ConnectFunction · 0.92
closeConnFunction · 0.70
ensureConnValidFunction · 0.70
PrepareMethod · 0.65
CloseMethod · 0.65
ExecPreparedMethod · 0.45
DeallocateMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected