| 155 | } |
| 156 | |
| 157 | func (m *mockService) Terminate(ctx context.Context) error { |
| 158 | select { |
| 159 | case <-ctx.Done(): |
| 160 | return fmt.Errorf("context canceled: %w", ctx.Err()) |
| 161 | default: |
| 162 | } |
| 163 | |
| 164 | if m.terminateDelay > 0 { |
| 165 | timer := time.NewTimer(m.terminateDelay) |
| 166 | select { |
| 167 | case <-ctx.Done(): |
| 168 | timer.Stop() |
| 169 | return fmt.Errorf("context canceled: %w", ctx.Err()) |
| 170 | case <-timer.C: |
| 171 | // Continue after delay |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | if m.terminateError != nil { |
| 176 | m.terminated = false |
| 177 | return m.terminateError |
| 178 | } |
| 179 | |
| 180 | m.started = false |
| 181 | m.terminated = true |
| 182 | return nil |
| 183 | } |
| 184 | |
| 185 | func Test_HasConfiguredServices(t *testing.T) { |
| 186 | testHasConfiguredServicesFn := func(t *testing.T, app *App, expected bool) { |