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

Function TestWithStopInit

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

Source from the content-addressed store, hash-verified

321}
322
323func TestWithStopInit(t *testing.T) {
324 t.Parallel()
325
326 testService(t, func(t *testing.T) serviceWithStopped {
327 t.Helper()
328 return &sampleServiceWithStopInit{didStop: true}
329 })
330
331 ctx := context.Background()
332
333 type testBundle struct{}
334
335 setup := func() (*sampleServiceWithStopInit, *testBundle) {
336 return &sampleServiceWithStopInit{}, &testBundle{}
337 }
338
339 t.Run("FinalizeDidStop", func(t *testing.T) {
340 t.Parallel()
341
342 service, _ := setup()
343 service.didStop = true // will set stopped
344
345 require.NoError(t, service.Start(ctx))
346
347 service.Stop()
348
349 require.Nil(t, service.started)
350 require.Nil(t, service.stopped)
351 })
352
353 t.Run("FinalizeDidNotStop", func(t *testing.T) {
354 t.Parallel()
355
356 service, _ := setup()
357 service.didStop = false // will NOT set stopped
358
359 require.NoError(t, service.Start(ctx))
360
361 service.Stop()
362
363 // service is still started because didStop was set to false
364 require.NotNil(t, service.started)
365 require.NotNil(t, service.stopped)
366 })
367}
368
369func TestStopped(t *testing.T) {
370 t.Parallel()

Callers

nothing calls this directly

Calls 5

testServiceFunction · 0.70
HelperMethod · 0.65
RunMethod · 0.65
StartMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…