MCPcopy
hub / github.com/riverqueue/river / Test_Client_JobDeleteMany

Function Test_Client_JobDeleteMany

client_test.go:2938–3180  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2936}
2937
2938func 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 })

Callers

nothing calls this directly

Calls 15

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
JobFunction · 0.92
MapFunction · 0.92
PtrFunction · 0.92
newTestClientFunction · 0.85
NewJobDeleteManyParamsFunction · 0.85
JobGetMethod · 0.80
UnsafeAllMethod · 0.80
newTestConfigFunction · 0.70
HelperMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…