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

Function Test_Client_JobList

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

Source from the content-addressed store, hash-verified

4741}
4742
4743func Test_Client_JobList(t *testing.T) {
4744 t.Parallel()
4745
4746 ctx := context.Background()
4747
4748 type testBundle struct {
4749 exec riverdriver.Executor
4750 schema string
4751 }
4752
4753 setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) {
4754 t.Helper()
4755
4756 var (
4757 dbPool = riversharedtest.DBPool(ctx, t)
4758 driver = riverpgxv5.New(dbPool)
4759 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
4760 config = newTestConfig(t, schema)
4761 client = newTestClient(t, dbPool, config)
4762 )
4763
4764 return client, &testBundle{
4765 exec: client.driver.GetExecutor(),
4766 schema: schema,
4767 }
4768 }
4769
4770 t.Run("FiltersByID", func(t *testing.T) {
4771 t.Parallel()
4772
4773 client, bundle := setup(t)
4774
4775 job1 := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema})
4776 job2 := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema})
4777 job3 := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema})
4778
4779 listRes, err := client.JobList(ctx, NewJobListParams().IDs(job1.ID))
4780 require.NoError(t, err)
4781 require.Equal(t, []int64{job1.ID}, sliceutil.Map(listRes.Jobs, func(job *rivertype.JobRow) int64 { return job.ID }))
4782
4783 listRes, err = client.JobList(ctx, NewJobListParams().IDs(job2.ID, job3.ID))
4784 require.NoError(t, err)
4785 require.Equal(t, []int64{job2.ID, job3.ID}, sliceutil.Map(listRes.Jobs, func(job *rivertype.JobRow) int64 { return job.ID }))
4786 })
4787
4788 t.Run("FiltersByIDAndPriorityAndKind", func(t *testing.T) {
4789 t.Parallel()
4790
4791 client, bundle := setup(t)
4792
4793 job1 := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, Kind: ptrutil.Ptr("special_kind"), Priority: ptrutil.Ptr(1)})
4794 job2 := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, Kind: ptrutil.Ptr("special_kind"), Priority: ptrutil.Ptr(2)})
4795 job3 := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, Kind: ptrutil.Ptr("other_kind"), Priority: ptrutil.Ptr(1)})
4796
4797 listRes, err := client.JobList(ctx, NewJobListParams().IDs(job1.ID, job2.ID, job3.ID).Priorities(1, 2).Kinds("special_kind"))
4798 require.NoError(t, err)
4799 require.Equal(t, []int64{job1.ID, job2.ID}, sliceutil.Map(listRes.Jobs, func(job *rivertype.JobRow) int64 { return job.ID }))
4800 })

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
NewJobListParamsFunction · 0.85
JobListCursorFromJobFunction · 0.85
OrderByMethod · 0.80
AfterMethod · 0.80
MetadataMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…