(t *testing.T)
| 864 | } |
| 865 | |
| 866 | func TestRequireManyInsertedTx(t *testing.T) { |
| 867 | t.Parallel() |
| 868 | |
| 869 | ctx := context.Background() |
| 870 | |
| 871 | type testBundle struct { |
| 872 | mockT *testutil.MockT |
| 873 | tx pgx.Tx |
| 874 | } |
| 875 | |
| 876 | setup := func(t *testing.T) (*river.Client[pgx.Tx], *testBundle) { |
| 877 | t.Helper() |
| 878 | |
| 879 | riverClient, err := river.NewClient(riverpgxv5.New(nil), &river.Config{}) |
| 880 | require.NoError(t, err) |
| 881 | |
| 882 | return riverClient, &testBundle{ |
| 883 | mockT: testutil.NewMockT(t), |
| 884 | tx: riverdbtest.TestTxPgx(ctx, t), |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | t.Run("VerifiesInsert", func(t *testing.T) { |
| 889 | t.Parallel() |
| 890 | |
| 891 | riverClient, bundle := setup(t) |
| 892 | |
| 893 | _, err := riverClient.InsertTx(ctx, bundle.tx, Job1Args{String: "foo"}, nil) |
| 894 | require.NoError(t, err) |
| 895 | |
| 896 | jobs := requireManyInsertedTx[*riverpgxv5.Driver](ctx, bundle.mockT, bundle.tx, []ExpectedJob{ |
| 897 | {Args: &Job1Args{}}, |
| 898 | }) |
| 899 | require.False(t, bundle.mockT.Failed) |
| 900 | require.Equal(t, "job1", jobs[0].Kind) |
| 901 | }) |
| 902 | |
| 903 | t.Run("TransactionVisibility", func(t *testing.T) { |
| 904 | t.Parallel() |
| 905 | |
| 906 | riverClient, bundle := setup(t) |
| 907 | |
| 908 | // Start a second transaction with different visibility. |
| 909 | otherTx := riverdbtest.TestTxPgx(ctx, t) |
| 910 | |
| 911 | _, err := riverClient.InsertTx(ctx, bundle.tx, Job1Args{String: "foo"}, nil) |
| 912 | require.NoError(t, err) |
| 913 | |
| 914 | // Visible in the original transaction. |
| 915 | jobs := requireManyInsertedTx[*riverpgxv5.Driver](ctx, bundle.mockT, bundle.tx, []ExpectedJob{ |
| 916 | {Args: &Job1Args{}}, |
| 917 | }) |
| 918 | require.False(t, bundle.mockT.Failed) |
| 919 | require.Equal(t, "job1", jobs[0].Kind) |
| 920 | |
| 921 | // Not visible in the second transaction. |
| 922 | _ = requireManyInsertedTx[*riverpgxv5.Driver](ctx, bundle.mockT, otherTx, []ExpectedJob{ |
| 923 | {Args: &Job1Args{}}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…