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)
| 452 | // driver and options for greater flexibility, including allowing for Pro |
| 453 | // drivers, while still sharing common setup like schema search path. |
| 454 | func 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. |
| 472 | type TestTxOpts struct { |
no test coverage detected
searching dependent graphs…