MCPcopy Index your code
hub / github.com/riverqueue/river / TestRequireManyInserted

Function TestRequireManyInserted

rivertest/rivertest_test.go:750–864  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
750func 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"}},

Callers

nothing calls this directly

Calls 12

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
NewClientFunction · 0.92
NewMockTFunction · 0.92
requireManyInsertedFunction · 0.85
failureStringFunction · 0.85
InsertMethod · 0.80
LogOutputMethod · 0.80
HelperMethod · 0.65
RunMethod · 0.65
InsertManyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…