MCPcopy
hub / github.com/riverqueue/river / Test_Client_Common

Function Test_Client_Common

client_test.go:252–2097  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

250}
251
252func 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

Callers

nothing calls this directly

Calls 15

DBPoolCloneFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
WaitOrTimeoutFunction · 0.92
WithTxFunction · 0.92
QueueFunction · 0.92
StressFunction · 0.92
NewClientFunction · 0.85
AddWorkerFunction · 0.85
WorkFuncFunction · 0.85
newTestClientFunction · 0.85
JobSnoozeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…