(t *testing.T)
| 321 | } |
| 322 | |
| 323 | func 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 | |
| 369 | func TestStopped(t *testing.T) { |
| 370 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…