Work inserts a job with the provided arguments and optional insert options, then works it. The transaction is used for all work-related database operations so that the caller can easily roll back at the end of the test to maintain a clean database state. The returned WorkResult contains the updated
(ctx context.Context, tb testing.TB, tx TTx, args T, opts *river.InsertOpts)
| 102 | // The returned error only reflects _real_ errors and does not include |
| 103 | // explicitly returned snooze or cancel errors from the worker. |
| 104 | func (w *Worker[T, TTx]) Work(ctx context.Context, tb testing.TB, tx TTx, args T, opts *river.InsertOpts) (*WorkResult, error) { |
| 105 | tb.Helper() |
| 106 | |
| 107 | job, err := w.insertJob(ctx, tb, tx, args, opts) |
| 108 | if err != nil { |
| 109 | return nil, fmt.Errorf("failed to insert job: %w", err) |
| 110 | } |
| 111 | return w.WorkJob(ctx, tb, tx, job) |
| 112 | } |
| 113 | |
| 114 | // WorkJob works an existing job already in the database. The job must be |
| 115 | // inserted using external logic prior to calling this method. The transaction |