(ctx context.Context, t *testing.T, driverWithSchema func(ctx context.Context, t *testing.T, opts *riverdbtest.TestSchemaOpts) (riverdriver.Driver[TTx], string), executorWithTx func(ctx context.Context, t *testing.T) (riverdriver.Executor, riverdriver.Driver[TTx]), )
| 25 | ) |
| 26 | |
| 27 | func exerciseJobInsert[TTx any](ctx context.Context, t *testing.T, |
| 28 | driverWithSchema func(ctx context.Context, t *testing.T, opts *riverdbtest.TestSchemaOpts) (riverdriver.Driver[TTx], string), |
| 29 | executorWithTx func(ctx context.Context, t *testing.T) (riverdriver.Executor, riverdriver.Driver[TTx]), |
| 30 | ) { |
| 31 | t.Helper() |
| 32 | |
| 33 | type testBundle struct { |
| 34 | driver riverdriver.Driver[TTx] |
| 35 | } |
| 36 | |
| 37 | setup := func(ctx context.Context, t *testing.T) (riverdriver.Executor, *testBundle) { |
| 38 | t.Helper() |
| 39 | |
| 40 | exec, driver := executorWithTx(ctx, t) |
| 41 | |
| 42 | return exec, &testBundle{ |
| 43 | driver: driver, |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | t.Run("JobInsertFastMany", func(t *testing.T) { |
| 48 | t.Parallel() |
| 49 | |
| 50 | t.Run("AllArgs", func(t *testing.T) { |
| 51 | t.Parallel() |
| 52 | |
| 53 | exec, bundle := setup(ctx, t) |
| 54 | |
| 55 | var ( |
| 56 | idStart = rand.Int64() |
| 57 | now = time.Now().UTC() |
| 58 | ) |
| 59 | |
| 60 | insertParams := make([]*riverdriver.JobInsertFastParams, 10) |
| 61 | for i := range insertParams { |
| 62 | insertParams[i] = &riverdriver.JobInsertFastParams{ |
| 63 | ID: ptrutil.Ptr(idStart + int64(i)), |
| 64 | CreatedAt: ptrutil.Ptr(now.Add(time.Duration(i) * 5 * time.Second)), |
| 65 | EncodedArgs: []byte(`{"encoded": "args"}`), |
| 66 | Kind: "test_kind", |
| 67 | MaxAttempts: rivercommon.MaxAttemptsDefault, |
| 68 | Metadata: []byte(`{"meta": "data"}`), |
| 69 | Priority: rivercommon.PriorityDefault, |
| 70 | Queue: rivercommon.QueueDefault, |
| 71 | ScheduledAt: ptrutil.Ptr(now.Add(time.Duration(i) * time.Minute)), |
| 72 | State: rivertype.JobStateAvailable, |
| 73 | Tags: []string{"tag"}, |
| 74 | UniqueKey: []byte("unique-key-fast-many-" + strconv.Itoa(i)), |
| 75 | UniqueStates: 0xff, |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | resultRows, err := exec.JobInsertFastMany(ctx, &riverdriver.JobInsertFastManyParams{ |
| 80 | Jobs: insertParams, |
| 81 | }) |
| 82 | require.NoError(t, err) |
| 83 | require.Len(t, resultRows, len(insertParams)) |
| 84 |
no test coverage detected
searching dependent graphs…