(t *testing.T)
| 2936 | } |
| 2937 | |
| 2938 | func Test_Client_JobDeleteMany(t *testing.T) { |
| 2939 | t.Parallel() |
| 2940 | |
| 2941 | ctx := context.Background() |
| 2942 | |
| 2943 | type testBundle struct { |
| 2944 | exec riverdriver.Executor |
| 2945 | schema string |
| 2946 | } |
| 2947 | |
| 2948 | setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) { |
| 2949 | t.Helper() |
| 2950 | |
| 2951 | var ( |
| 2952 | dbPool = riversharedtest.DBPool(ctx, t) |
| 2953 | driver = riverpgxv5.New(dbPool) |
| 2954 | schema = riverdbtest.TestSchema(ctx, t, driver, nil) |
| 2955 | config = newTestConfig(t, schema) |
| 2956 | client = newTestClient(t, dbPool, config) |
| 2957 | ) |
| 2958 | |
| 2959 | return client, &testBundle{ |
| 2960 | exec: client.driver.GetExecutor(), |
| 2961 | schema: schema, |
| 2962 | } |
| 2963 | } |
| 2964 | |
| 2965 | t.Run("FiltersByID", func(t *testing.T) { |
| 2966 | t.Parallel() |
| 2967 | |
| 2968 | client, bundle := setup(t) |
| 2969 | |
| 2970 | var ( |
| 2971 | job1 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema}) |
| 2972 | job2 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema}) |
| 2973 | job3 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema}) |
| 2974 | job4 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema}) |
| 2975 | ) |
| 2976 | |
| 2977 | deleteRes, err := client.JobDeleteMany(ctx, NewJobDeleteManyParams().IDs(job1.ID)) |
| 2978 | require.NoError(t, err) |
| 2979 | require.Equal(t, []int64{job1.ID}, sliceutil.Map(deleteRes.Jobs, func(job *rivertype.JobRow) int64 { return job.ID })) |
| 2980 | |
| 2981 | _, err = bundle.exec.JobGetByID(ctx, &riverdriver.JobGetByIDParams{ID: job1.ID, Schema: bundle.schema}) |
| 2982 | require.ErrorIs(t, rivertype.ErrNotFound, err) |
| 2983 | _, err = client.JobGet(ctx, job2.ID) |
| 2984 | require.NoError(t, err) |
| 2985 | _, err = client.JobGet(ctx, job3.ID) |
| 2986 | require.NoError(t, err) |
| 2987 | |
| 2988 | deleteRes, err = client.JobDeleteMany(ctx, NewJobDeleteManyParams().IDs(job2.ID, job3.ID)) |
| 2989 | require.NoError(t, err) |
| 2990 | require.Equal(t, []int64{job2.ID, job3.ID}, sliceutil.Map(deleteRes.Jobs, func(job *rivertype.JobRow) int64 { return job.ID })) |
| 2991 | |
| 2992 | // job4 should still be present |
| 2993 | _, err = client.JobGet(ctx, job4.ID) |
| 2994 | require.NoError(t, err) |
| 2995 | }) |
nothing calls this directly
no test coverage detected
searching dependent graphs…