The tests for this function are quite minimal because it uses the same implementation as the `*Tx` variant, so most of the test happens below.
(t *testing.T)
| 389 | // The tests for this function are quite minimal because it uses the same |
| 390 | // implementation as the `*Tx` variant, so most of the test happens below. |
| 391 | func TestRequireNotInserted(t *testing.T) { |
| 392 | t.Parallel() |
| 393 | |
| 394 | ctx := context.Background() |
| 395 | |
| 396 | type testBundle struct { |
| 397 | dbPool *pgxpool.Pool |
| 398 | driver *riverpgxv5.Driver |
| 399 | mockT *testutil.MockT |
| 400 | schema string |
| 401 | schemaOpts *RequireInsertedOpts |
| 402 | } |
| 403 | |
| 404 | setup := func(t *testing.T) (*river.Client[pgx.Tx], *testBundle) { |
| 405 | t.Helper() |
| 406 | |
| 407 | var ( |
| 408 | dbPool = riversharedtest.DBPool(ctx, t) |
| 409 | driver = riverpgxv5.New(dbPool) |
| 410 | schema = riverdbtest.TestSchema(ctx, t, driver, nil) |
| 411 | ) |
| 412 | |
| 413 | riverClient, err := river.NewClient(driver, &river.Config{ |
| 414 | Schema: schema, |
| 415 | }) |
| 416 | require.NoError(t, err) |
| 417 | |
| 418 | return riverClient, &testBundle{ |
| 419 | dbPool: dbPool, |
| 420 | driver: driver, |
| 421 | mockT: testutil.NewMockT(t), |
| 422 | schema: schema, |
| 423 | schemaOpts: &RequireInsertedOpts{Schema: schema}, |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | t.Run("VerifiesNotInsert", func(t *testing.T) { |
| 428 | t.Parallel() |
| 429 | |
| 430 | riverClient, bundle := setup(t) |
| 431 | |
| 432 | _, err := riverClient.Insert(ctx, Job2Args{Int: 123}, nil) |
| 433 | require.NoError(t, err) |
| 434 | |
| 435 | requireNotInserted(ctx, t, bundle.driver, &Job1Args{}, bundle.schemaOpts) |
| 436 | require.False(t, bundle.mockT.Failed) |
| 437 | }) |
| 438 | } |
| 439 | |
| 440 | func TestRequireNotInsertedTx(t *testing.T) { |
| 441 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…