(t *testing.T)
| 4741 | } |
| 4742 | |
| 4743 | func 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 | }) |
nothing calls this directly
no test coverage detected
searching dependent graphs…