| 37 | } |
| 38 | |
| 39 | func TestWorker_NewWorker(t *testing.T) { |
| 40 | t.Parallel() |
| 41 | |
| 42 | ctx := context.Background() |
| 43 | |
| 44 | type testBundle struct { |
| 45 | config *river.Config |
| 46 | driver *riverpgxv5.Driver |
| 47 | tx pgx.Tx |
| 48 | } |
| 49 | |
| 50 | setup := func(t *testing.T) *testBundle { |
| 51 | t.Helper() |
| 52 | |
| 53 | return &testBundle{ |
| 54 | config: &river.Config{ID: "rivertest-worker"}, |
| 55 | driver: riverpgxv5.New(nil), |
| 56 | tx: riverdbtest.TestTxPgx(ctx, t), |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | t.Run("HandlesNilRiverConfig", func(t *testing.T) { |
| 61 | t.Parallel() |
| 62 | |
| 63 | bundle := setup(t) |
| 64 | |
| 65 | worker := river.WorkFunc(func(ctx context.Context, job *river.Job[testArgs]) error { |
| 66 | return nil |
| 67 | }) |
| 68 | tw := NewWorker(t, bundle.driver, nil, worker) |
| 69 | require.NotNil(t, tw.config) |
| 70 | }) |
| 71 | } |
| 72 | |
| 73 | func TestWorker_Work(t *testing.T) { |
| 74 | t.Parallel() |