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)
| 35 | // The tests for this function are quite minimal because it uses the same |
| 36 | // implementation as the `*Tx` variant, so most of the test happens below. |
| 37 | func TestRequireInserted(t *testing.T) { |
| 38 | t.Parallel() |
| 39 | |
| 40 | ctx := context.Background() |
| 41 | |
| 42 | type testBundle struct { |
| 43 | dbPool *pgxpool.Pool |
| 44 | driver *riverpgxv5.Driver |
| 45 | mockT *testutil.MockT |
| 46 | schema string |
| 47 | schemaOpts *RequireInsertedOpts |
| 48 | } |
| 49 | |
| 50 | setup := func(t *testing.T) (*river.Client[pgx.Tx], *testBundle) { |
| 51 | t.Helper() |
| 52 | |
| 53 | var ( |
| 54 | dbPool = riversharedtest.DBPool(ctx, t) |
| 55 | driver = riverpgxv5.New(dbPool) |
| 56 | schema = riverdbtest.TestSchema(ctx, t, driver, nil) |
| 57 | ) |
| 58 | |
| 59 | riverClient, err := river.NewClient(driver, &river.Config{ |
| 60 | Schema: schema, |
| 61 | }) |
| 62 | require.NoError(t, err) |
| 63 | |
| 64 | return riverClient, &testBundle{ |
| 65 | dbPool: dbPool, |
| 66 | driver: driver, |
| 67 | mockT: testutil.NewMockT(t), |
| 68 | schema: schema, |
| 69 | schemaOpts: &RequireInsertedOpts{Schema: schema}, |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | t.Run("VerifiesInsert", func(t *testing.T) { |
| 74 | t.Parallel() |
| 75 | |
| 76 | riverClient, bundle := setup(t) |
| 77 | |
| 78 | _, err := riverClient.Insert(ctx, Job1Args{String: "foo"}, nil) |
| 79 | require.NoError(t, err) |
| 80 | |
| 81 | job := requireInserted(ctx, t, bundle.driver, &Job1Args{}, bundle.schemaOpts) |
| 82 | require.False(t, bundle.mockT.Failed) |
| 83 | require.Equal(t, "foo", job.Args.String) |
| 84 | }) |
| 85 | } |
| 86 | |
| 87 | func TestRequireInsertedTx(t *testing.T) { |
| 88 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…