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

Function Test_Client_JobGet

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

Source from the content-addressed store, hash-verified

4693}
4694
4695func Test_Client_JobGet(t *testing.T) {
4696 t.Parallel()
4697
4698 ctx := context.Background()
4699
4700 type testBundle struct{}
4701
4702 setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) {
4703 t.Helper()
4704
4705 var (
4706 dbPool = riversharedtest.DBPool(ctx, t)
4707 driver = riverpgxv5.New(dbPool)
4708 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
4709 config = newTestConfig(t, schema)
4710 client = newTestClient(t, dbPool, config)
4711 )
4712
4713 return client, &testBundle{}
4714 }
4715
4716 t.Run("FetchesAnExistingJob", func(t *testing.T) {
4717 t.Parallel()
4718
4719 client, _ := setup(t)
4720
4721 insertRes, err := client.Insert(ctx, noOpArgs{}, nil)
4722 require.NoError(t, err)
4723
4724 job, err := client.JobGet(ctx, insertRes.Job.ID)
4725 require.NoError(t, err)
4726
4727 require.Equal(t, insertRes.Job.ID, job.ID)
4728 require.Equal(t, insertRes.Job.State, job.State)
4729 })
4730
4731 t.Run("ReturnsErrNotFoundIfJobDoesNotExist", func(t *testing.T) {
4732 t.Parallel()
4733
4734 client, _ := setup(t)
4735
4736 job, err := client.JobGet(ctx, 0)
4737 require.Error(t, err)
4738 require.ErrorIs(t, err, ErrNotFound)
4739 require.Nil(t, job)
4740 })
4741}
4742
4743func Test_Client_JobList(t *testing.T) {
4744 t.Parallel()

Callers

nothing calls this directly

Calls 10

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
newTestClientFunction · 0.85
InsertMethod · 0.80
JobGetMethod · 0.80
newTestConfigFunction · 0.70
HelperMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…