(ctx context.Context, ctrl *gomock.Controller)
| 25 | } |
| 26 | |
| 27 | func waitForMocks(ctx context.Context, ctrl *gomock.Controller) error { |
| 28 | ticker := time.NewTicker(1 * time.Millisecond) |
| 29 | defer ticker.Stop() |
| 30 | |
| 31 | timeout := time.After(3 * time.Millisecond) |
| 32 | |
| 33 | for { |
| 34 | select { |
| 35 | case <-ticker.C: |
| 36 | if ctrl.Satisfied() { |
| 37 | return nil |
| 38 | } |
| 39 | case <-timeout: |
| 40 | return fmt.Errorf("timeout waiting for mocks to be satisfied") |
| 41 | case <-ctx.Done(): |
| 42 | return fmt.Errorf("context cancelled") |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | // TestConcurrentFails is expected to fail (and is disabled). It |
| 48 | // demonstrates how to use gomock.WithContext to interrupt the test |
no test coverage detected