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

Function TestStopAllParallel

rivershared/startstop/start_stop_test.go:549–601  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

547}
548
549func TestStopAllParallel(t *testing.T) {
550 t.Parallel()
551
552 ctx := context.Background()
553
554 t.Run("Started", func(t *testing.T) {
555 t.Parallel()
556
557 var (
558 service1 = &sampleService{}
559 service2 = &sampleService{}
560 service3 = &sampleService{}
561 )
562
563 require.NoError(t, service1.Start(ctx))
564 require.NoError(t, service2.Start(ctx))
565 require.NoError(t, service3.Start(ctx))
566
567 var (
568 stopped1 = service1.Stopped()
569 stopped2 = service2.Stopped()
570 stopped3 = service3.Stopped()
571 )
572
573 StopAllParallel(
574 service1,
575 service2,
576 service3,
577 )
578
579 riversharedtest.WaitOrTimeout(t, stopped1)
580 riversharedtest.WaitOrTimeout(t, stopped2)
581 riversharedtest.WaitOrTimeout(t, stopped3)
582 })
583
584 // We can't use the stopped channels in this case because they're only
585 // initiated when a service is started.
586 t.Run("NotStarted", func(t *testing.T) {
587 t.Parallel()
588
589 var (
590 service1 = &sampleService{}
591 service2 = &sampleService{}
592 service3 = &sampleService{}
593 )
594
595 StopAllParallel(
596 service1,
597 service2,
598 service3,
599 )
600 })
601}
602
603func TestWaitAllStarted(t *testing.T) {
604 t.Parallel()

Callers

nothing calls this directly

Calls 5

WaitOrTimeoutFunction · 0.92
StopAllParallelFunction · 0.85
RunMethod · 0.65
StartMethod · 0.65
StoppedMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…