(ctx context.Context, expectedState State, ch chan struct{})
| 294 | } |
| 295 | |
| 296 | func (b *BasicService) awaitState(ctx context.Context, expectedState State, ch chan struct{}) error { |
| 297 | select { |
| 298 | case <-ctx.Done(): |
| 299 | return ctx.Err() |
| 300 | case <-ch: |
| 301 | s := b.State() |
| 302 | if s == expectedState { |
| 303 | return nil |
| 304 | } |
| 305 | |
| 306 | // if service has failed, include failure case in the returned error. |
| 307 | if failure := b.FailureCase(); failure != nil { |
| 308 | return invalidServiceStateWithFailureError(s, expectedState, failure) |
| 309 | } |
| 310 | |
| 311 | return invalidServiceStateError(s, expectedState) |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | // FailureCase is part of Service interface. |
| 316 | func (b *BasicService) FailureCase() error { |
no test coverage detected