(t *testing.T)
| 250 | } |
| 251 | |
| 252 | func Test_Client_Common(t *testing.T) { |
| 253 | t.Parallel() |
| 254 | |
| 255 | ctx := context.Background() |
| 256 | |
| 257 | type testBundle struct { |
| 258 | config *Config |
| 259 | dbPool *pgxpool.Pool |
| 260 | driver *riverpgxv5.Driver |
| 261 | schema string |
| 262 | } |
| 263 | |
| 264 | // Alternate setup returning only client Config rather than a full Client. |
| 265 | setupConfig := func(t *testing.T) (*Config, *testBundle) { |
| 266 | t.Helper() |
| 267 | |
| 268 | var ( |
| 269 | dbPool = riversharedtest.DBPoolClone(ctx, t) |
| 270 | driver = riverpgxv5.New(dbPool) |
| 271 | schema = riverdbtest.TestSchema(ctx, t, driver, nil) |
| 272 | config = newTestConfig(t, schema) |
| 273 | ) |
| 274 | |
| 275 | return config, &testBundle{ |
| 276 | config: config, |
| 277 | dbPool: dbPool, |
| 278 | driver: driver, |
| 279 | schema: schema, |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) { |
| 284 | t.Helper() |
| 285 | |
| 286 | config, bundle := setupConfig(t) |
| 287 | |
| 288 | client, err := NewClient(bundle.driver, config) |
| 289 | require.NoError(t, err) |
| 290 | |
| 291 | return client, bundle |
| 292 | } |
| 293 | |
| 294 | t.Run("StartInsertAndWork", func(t *testing.T) { |
| 295 | t.Parallel() |
| 296 | |
| 297 | client, _ := setup(t) |
| 298 | |
| 299 | type JobArgs struct { |
| 300 | testutil.JobArgsReflectKind[JobArgs] |
| 301 | } |
| 302 | |
| 303 | workedChan := make(chan struct{}) |
| 304 | |
| 305 | AddWorker(client.config.Workers, WorkFunc(func(ctx context.Context, job *Job[JobArgs]) error { |
| 306 | workedChan <- struct{}{} |
| 307 | return nil |
| 308 | })) |
| 309 |
nothing calls this directly
no test coverage detected
searching dependent graphs…