refactoring: TestProgressShutdownsWithErrFiller
Vladimir Bauer
3 years ago
| 196 | 196 | }), |
| 197 | 197 | ) |
| 198 | 198 | |
| 199 | for bar.IsRunning() { | |
| 200 | time.Sleep(randomDuration(100 * time.Millisecond)) | |
| 201 | bar.Increment() | |
| 202 | } | |
| 203 | ||
| 204 | go p.Wait() | |
| 199 | go func() { | |
| 200 | for bar.IsRunning() { | |
| 201 | bar.Increment() | |
| 202 | } | |
| 203 | }() | |
| 205 | 204 | |
| 206 | 205 | select { |
| 207 | 206 | case <-shutdown: |
| 211 | 210 | case <-time.After(timeout): |
| 212 | 211 | t.Errorf("Progress didn't shutdown after %v", timeout) |
| 213 | 212 | } |
| 213 | p.Wait() | |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | func randomDuration(max time.Duration) time.Duration { |