(t *testing.T)
| 438 | } |
| 439 | |
| 440 | func TestRequireNotInsertedTx(t *testing.T) { |
| 441 | t.Parallel() |
| 442 | |
| 443 | ctx := context.Background() |
| 444 | |
| 445 | type testBundle struct { |
| 446 | mockT *testutil.MockT |
| 447 | tx pgx.Tx |
| 448 | } |
| 449 | |
| 450 | setup := func(t *testing.T) (*river.Client[pgx.Tx], *testBundle) { |
| 451 | t.Helper() |
| 452 | |
| 453 | riverClient, err := river.NewClient(riverpgxv5.New(nil), &river.Config{}) |
| 454 | require.NoError(t, err) |
| 455 | |
| 456 | return riverClient, &testBundle{ |
| 457 | mockT: testutil.NewMockT(t), |
| 458 | tx: riverdbtest.TestTxPgx(ctx, t), |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | t.Run("VerifiesInsert", func(t *testing.T) { |
| 463 | t.Parallel() |
| 464 | |
| 465 | riverClient, bundle := setup(t) |
| 466 | |
| 467 | _, err := riverClient.InsertTx(ctx, bundle.tx, Job2Args{Int: 123}, nil) |
| 468 | require.NoError(t, err) |
| 469 | |
| 470 | requireNotInsertedTx[*riverpgxv5.Driver](ctx, t, bundle.tx, &Job1Args{}, nil) |
| 471 | require.False(t, bundle.mockT.Failed) |
| 472 | }) |
| 473 | |
| 474 | t.Run("VerifiesMultiple", func(t *testing.T) { |
| 475 | t.Parallel() |
| 476 | |
| 477 | _, bundle := setup(t) |
| 478 | |
| 479 | requireNotInsertedTx[*riverpgxv5.Driver](ctx, t, bundle.tx, &Job1Args{}, nil) |
| 480 | require.False(t, bundle.mockT.Failed) |
| 481 | |
| 482 | requireNotInsertedTx[*riverpgxv5.Driver](ctx, t, bundle.tx, &Job2Args{}, nil) |
| 483 | require.False(t, bundle.mockT.Failed) |
| 484 | }) |
| 485 | |
| 486 | t.Run("TransactionVisibility", func(t *testing.T) { |
| 487 | t.Parallel() |
| 488 | |
| 489 | riverClient, bundle := setup(t) |
| 490 | |
| 491 | // Start a second transaction with different visibility. |
| 492 | otherTx := riverdbtest.TestTxPgx(ctx, t) |
| 493 | |
| 494 | _, err := riverClient.InsertTx(ctx, bundle.tx, Job1Args{String: "foo"}, nil) |
| 495 | require.NoError(t, err) |
| 496 | |
| 497 | // Not visible in the second transaction. |
nothing calls this directly
no test coverage detected
searching dependent graphs…