(t *testing.T)
| 115 | } |
| 116 | |
| 117 | func TestWorkFunc(t *testing.T) { |
| 118 | t.Parallel() |
| 119 | |
| 120 | ctx := context.Background() |
| 121 | |
| 122 | type testBundle struct{} |
| 123 | |
| 124 | setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) { |
| 125 | t.Helper() |
| 126 | |
| 127 | var ( |
| 128 | dbPool = riversharedtest.DBPool(ctx, t) |
| 129 | driver = riverpgxv5.New(dbPool) |
| 130 | schema = riverdbtest.TestSchema(ctx, t, driver, nil) |
| 131 | config = newTestConfig(t, schema) |
| 132 | client = newTestClient(t, dbPool, config) |
| 133 | ) |
| 134 | |
| 135 | startClient(ctx, t, client) |
| 136 | |
| 137 | return client, &testBundle{} |
| 138 | } |
| 139 | |
| 140 | t.Run("RoundTrip", func(t *testing.T) { |
| 141 | t.Parallel() |
| 142 | |
| 143 | client, _ := setup(t) |
| 144 | |
| 145 | workChan := make(chan struct{}) |
| 146 | AddWorker(client.config.Workers, WorkFunc(func(ctx context.Context, job *Job[WorkFuncArgs]) error { |
| 147 | workChan <- struct{}{} |
| 148 | return nil |
| 149 | })) |
| 150 | |
| 151 | _, err := client.Insert(ctx, &WorkFuncArgs{}, nil) |
| 152 | require.NoError(t, err) |
| 153 | |
| 154 | riversharedtest.WaitOrTimeout(t, workChan) |
| 155 | }) |
| 156 | |
| 157 | t.Run("StructFunction", func(t *testing.T) { |
| 158 | t.Parallel() |
| 159 | |
| 160 | client, _ := setup(t) |
| 161 | |
| 162 | structWithFunc := &StructWithFunc{ |
| 163 | WorkChan: make(chan struct{}), |
| 164 | } |
| 165 | |
| 166 | AddWorker(client.config.Workers, WorkFunc(structWithFunc.Work)) |
| 167 | |
| 168 | _, err := client.Insert(ctx, &WorkFuncArgs{}, nil) |
| 169 | require.NoError(t, err) |
| 170 | |
| 171 | riversharedtest.WaitOrTimeout(t, structWithFunc.WorkChan) |
| 172 | }) |
| 173 | |
| 174 | t.Run("JobArgsReflectKind", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…