(t *testing.T)
| 3180 | } |
| 3181 | |
| 3182 | func Test_Client_JobDeleteManyTx(t *testing.T) { |
| 3183 | t.Parallel() |
| 3184 | |
| 3185 | ctx := context.Background() |
| 3186 | |
| 3187 | type testBundle struct { |
| 3188 | dbPool *pgxpool.Pool |
| 3189 | exec riverdriver.Executor |
| 3190 | execTx riverdriver.ExecutorTx |
| 3191 | schema string |
| 3192 | tx pgx.Tx |
| 3193 | } |
| 3194 | |
| 3195 | setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) { |
| 3196 | t.Helper() |
| 3197 | |
| 3198 | var ( |
| 3199 | dbPool = riversharedtest.DBPool(ctx, t) |
| 3200 | driver = riverpgxv5.New(dbPool) |
| 3201 | schema = riverdbtest.TestSchema(ctx, t, driver, nil) |
| 3202 | config = newTestConfig(t, schema) |
| 3203 | client = newTestClient(t, dbPool, config) |
| 3204 | ) |
| 3205 | |
| 3206 | tx, err := dbPool.Begin(ctx) |
| 3207 | require.NoError(t, err) |
| 3208 | t.Cleanup(func() { tx.Rollback(ctx) }) |
| 3209 | |
| 3210 | return client, &testBundle{ |
| 3211 | dbPool: dbPool, |
| 3212 | exec: driver.GetExecutor(), |
| 3213 | execTx: driver.UnwrapExecutor(tx), |
| 3214 | schema: schema, |
| 3215 | tx: tx, |
| 3216 | } |
| 3217 | } |
| 3218 | |
| 3219 | t.Run("Succeeds", func(t *testing.T) { |
| 3220 | t.Parallel() |
| 3221 | |
| 3222 | client, bundle := setup(t) |
| 3223 | |
| 3224 | job1 := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema}) |
| 3225 | job2 := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema}) |
| 3226 | job3 := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema}) |
| 3227 | |
| 3228 | deleteRes, err := client.JobDeleteManyTx(ctx, bundle.tx, NewJobDeleteManyParams().IDs(job1.ID)) |
| 3229 | require.NoError(t, err) |
| 3230 | require.Equal(t, []int64{job1.ID}, sliceutil.Map(deleteRes.Jobs, func(job *rivertype.JobRow) int64 { return job.ID })) |
| 3231 | |
| 3232 | _, err = bundle.execTx.JobGetByID(ctx, &riverdriver.JobGetByIDParams{ID: job1.ID, Schema: bundle.schema}) |
| 3233 | require.ErrorIs(t, rivertype.ErrNotFound, err) |
| 3234 | _, err = bundle.execTx.JobGetByID(ctx, &riverdriver.JobGetByIDParams{ID: job2.ID, Schema: bundle.schema}) |
| 3235 | require.NoError(t, err) |
| 3236 | _, err = bundle.execTx.JobGetByID(ctx, &riverdriver.JobGetByIDParams{ID: job3.ID, Schema: bundle.schema}) |
| 3237 | require.NoError(t, err) |
| 3238 | |
| 3239 | deleteRes, err = client.JobDeleteManyTx(ctx, bundle.tx, NewJobDeleteManyParams().IDs(job2.ID, job3.ID)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…