MCPcopy Index your code
hub / github.com/riverqueue/river / TestTxPgxDriver

Function TestTxPgxDriver

riverdbtest/riverdbtest.go:454–469  ·  view source on GitHub ↗

TestTxPgxDriver starts a test transaction that's rolled back automatically as the test case is cleaning itself up. Unlike TestTxPgx, this variant takes a driver and options for greater flexibility, including allowing for Pro drivers, while still sharing common setup like schema search path.

(ctx context.Context, tb testing.TB, driver riverdriver.Driver[pgx.Tx], opts *TestTxOpts)

Source from the content-addressed store, hash-verified

452// driver and options for greater flexibility, including allowing for Pro
453// drivers, while still sharing common setup like schema search path.
454func TestTxPgxDriver(ctx context.Context, tb testing.TB, driver riverdriver.Driver[pgx.Tx], opts *TestTxOpts) (pgx.Tx, string) {
455 tb.Helper()
456
457 var optsCopy TestTxOpts
458 if opts != nil {
459 optsCopy = *opts
460 }
461 optsCopy.IsTestTxHelper = true
462
463 tx, schema := TestTx(ctx, tb, driver, &optsCopy)
464
465 _, err := tx.Exec(ctx, "SET search_path TO '"+schema+"'")
466 require.NoError(tb, err)
467
468 return tx, schema
469}
470
471// TestTxOpts are options for TestTx. Most of the time these can be left as nil.
472type TestTxOpts struct {

Callers 4

TestElector_PollOnlyFunction · 0.92
TestTxPgxFunction · 0.85

Calls 3

TestTxFunction · 0.85
HelperMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…