MCPcopy Index your code
hub / github.com/riverqueue/river / Test_Client_Stop_AfterContextCancelled

Function Test_Client_Stop_AfterContextCancelled

client_test.go:2400–2440  ·  view source on GitHub ↗

Added this failing test case as skipped while working on another project, detecting a problem that the test case above was glossing over, but finding it not easy to fix so decided to punt. An initial Stop is called on the client with a cancelled context, but then Stop is called again with a non-can

(t *testing.T)

Source from the content-addressed store, hash-verified

2398//
2399// TODO: Remove the Skip below and fix the problem.
2400func Test_Client_Stop_AfterContextCancelled(t *testing.T) {
2401 t.Parallel()
2402
2403 t.Skip("this test case was added broken and should be fixed")
2404
2405 ctx := context.Background()
2406
2407 var (
2408 dbPool = riversharedtest.DBPool(ctx, t)
2409 driver = riverpgxv5.New(dbPool)
2410 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
2411 config = newTestConfig(t, schema)
2412 )
2413 config.Schema = schema
2414
2415 type JobArgs struct {
2416 testutil.JobArgsReflectKind[JobArgs]
2417 }
2418
2419 // doneCh will never close, job will exit due to context cancellation:
2420 var (
2421 doneCh = make(chan struct{})
2422 startedCh = make(chan int64)
2423 )
2424 AddWorker(config.Workers, makeAwaitWorker[JobArgs](startedCh, doneCh))
2425
2426 client := newTestClient(t, dbPool, config)
2427 subscribeChan := subscribe(t, client)
2428
2429 startClient(ctx, t, client)
2430
2431 insertRes, err := client.Insert(ctx, JobArgs{}, nil)
2432 require.NoError(t, err)
2433 event := riversharedtest.WaitOrTimeout(t, subscribeChan)
2434 require.Equal(t, insertRes.Job.ID, event.Job.ID)
2435
2436 ctx, cancel := context.WithCancel(ctx)
2437 cancel()
2438
2439 require.ErrorIs(t, client.Stop(ctx), context.Canceled)
2440}
2441
2442func Test_Client_StopAndCancel(t *testing.T) {
2443 t.Parallel()

Callers

nothing calls this directly

Calls 11

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
WaitOrTimeoutFunction · 0.92
AddWorkerFunction · 0.85
newTestClientFunction · 0.85
InsertMethod · 0.80
newTestConfigFunction · 0.70
subscribeFunction · 0.70
startClientFunction · 0.70
StopMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…