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

Function RunWithQueryExecModes

pgxtest/pgxtest.go:84–103  ·  view source on GitHub ↗

RunWithQueryExecModes runs a f in a new test for each element of modes with a new connection created using connector. If modes is nil all pgx.QueryExecModes are tested.

(ctx context.Context, t *testing.T, ctr ConnTestRunner, modes []pgx.QueryExecMode, f func(ctx context.Context, t testing.TB, conn *pgx.Conn))

Source from the content-addressed store, hash-verified

82// RunWithQueryExecModes runs a f in a new test for each element of modes with a new connection created using connector.
83// If modes is nil all pgx.QueryExecModes are tested.
84func RunWithQueryExecModes(ctx context.Context, t *testing.T, ctr ConnTestRunner, modes []pgx.QueryExecMode, f func(ctx context.Context, t testing.TB, conn *pgx.Conn)) {
85 if modes == nil {
86 modes = AllQueryExecModes
87 }
88
89 for _, mode := range modes {
90 ctrWithMode := ctr
91 ctrWithMode.CreateConfig = func(ctx context.Context, t testing.TB) *pgx.ConnConfig {
92 config := ctr.CreateConfig(ctx, t)
93 config.DefaultQueryExecMode = mode
94 return config
95 }
96
97 t.Run(mode.String(),
98 func(t *testing.T) {
99 ctrWithMode.RunTest(ctx, t, f)
100 },
101 )
102 }
103}
104
105type ValueRoundTripTest struct {
106 Param any

Callers 15

TestTraceExecFunction · 0.92
TestTraceQueryFunction · 0.92
TestTraceBatchNormalFunction · 0.92
TestTraceBatchCloseFunction · 0.92
TestTraceCopyFromFunction · 0.92
TestTracePrepareFunction · 0.92
TestTraceWithinTxFunction · 0.92
TestExecFunction · 0.92
TestExecFailureFunction · 0.92

Calls 3

RunTestMethod · 0.80
RunMethod · 0.45
StringMethod · 0.45

Tested by 15

TestTraceExecFunction · 0.74
TestTraceQueryFunction · 0.74
TestTraceBatchNormalFunction · 0.74
TestTraceBatchCloseFunction · 0.74
TestTraceCopyFromFunction · 0.74
TestTracePrepareFunction · 0.74
TestTraceWithinTxFunction · 0.74
TestExecFunction · 0.74
TestExecFailureFunction · 0.74