(t *testing.T)
| 187 | } |
| 188 | |
| 189 | func TestErrStop(t *testing.T) { |
| 190 | t.Parallel() |
| 191 | |
| 192 | var workCtx context.Context |
| 193 | |
| 194 | startStop := StartStopFunc(func(ctx context.Context, shouldStart bool, started, stopped func()) error { |
| 195 | if !shouldStart { |
| 196 | return nil |
| 197 | } |
| 198 | |
| 199 | workCtx = ctx //nolint:fatcontext |
| 200 | |
| 201 | go func() { |
| 202 | started() |
| 203 | defer stopped() |
| 204 | <-ctx.Done() |
| 205 | }() |
| 206 | |
| 207 | return nil |
| 208 | }) |
| 209 | |
| 210 | ctx := context.Background() |
| 211 | |
| 212 | require.NoError(t, startStop.Start(ctx)) |
| 213 | <-startStop.Started() |
| 214 | startStop.Stop() |
| 215 | require.ErrorIs(t, context.Cause(workCtx), ErrStop) |
| 216 | } |
| 217 | |
| 218 | // BaseStartStop tests that need specific internal implementation (like ones we |
| 219 | // can add to sampleService) to be able to verify. |
nothing calls this directly
no test coverage detected
searching dependent graphs…