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)
| 748 | // The tests for this function are quite minimal because it uses the same |
| 749 | // implementation as the `*Tx` variant, so most of the test happens below. |
| 750 | func TestRequireManyInserted(t *testing.T) { |
| 751 | t.Parallel() |
| 752 | |
| 753 | ctx := context.Background() |
| 754 | |
| 755 | type testBundle struct { |
| 756 | dbPool *pgxpool.Pool |
| 757 | driver *riverpgxv5.Driver |
| 758 | mockT *testutil.MockT |
| 759 | schema string |
| 760 | schemaOpts *RequireInsertedOpts |
| 761 | } |
| 762 | |
| 763 | setup := func(t *testing.T) (*river.Client[pgx.Tx], *testBundle) { |
| 764 | t.Helper() |
| 765 | |
| 766 | var ( |
| 767 | dbPool = riversharedtest.DBPool(ctx, t) |
| 768 | driver = riverpgxv5.New(dbPool) |
| 769 | schema = riverdbtest.TestSchema(ctx, t, driver, nil) |
| 770 | ) |
| 771 | |
| 772 | riverClient, err := river.NewClient(driver, &river.Config{ |
| 773 | Schema: schema, |
| 774 | }) |
| 775 | require.NoError(t, err) |
| 776 | |
| 777 | return riverClient, &testBundle{ |
| 778 | dbPool: dbPool, |
| 779 | driver: driver, |
| 780 | mockT: testutil.NewMockT(t), |
| 781 | schema: schema, |
| 782 | schemaOpts: &RequireInsertedOpts{Schema: schema}, |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | t.Run("VerifiesInsert", func(t *testing.T) { |
| 787 | t.Parallel() |
| 788 | |
| 789 | riverClient, bundle := setup(t) |
| 790 | |
| 791 | _, err := riverClient.Insert(ctx, Job1Args{String: "foo"}, nil) |
| 792 | require.NoError(t, err) |
| 793 | |
| 794 | jobs := requireManyInserted(ctx, bundle.mockT, bundle.driver, []ExpectedJob{ |
| 795 | {Args: &Job1Args{}, Opts: bundle.schemaOpts}, |
| 796 | }) |
| 797 | require.False(t, bundle.mockT.Failed) |
| 798 | require.Equal(t, "job1", jobs[0].Kind) |
| 799 | }) |
| 800 | |
| 801 | t.Run("SchemaInAllOptsOkay", func(t *testing.T) { |
| 802 | t.Parallel() |
| 803 | |
| 804 | riverClient, bundle := setup(t) |
| 805 | |
| 806 | _, err := riverClient.InsertMany(ctx, []river.InsertManyParams{ |
| 807 | {Args: Job1Args{String: "foo"}}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…