fixup! simplify TestWithContext
Vladimir Bauer
4 years ago
| 82 | 82 | |
| 83 | 83 | start := make(chan struct{}) |
| 84 | 84 | done := make(chan struct{}) |
| 85 | fail := make(chan struct{}) | |
| 85 | 86 | bar := p.AddBar(0) // never complete bar |
| 86 | 87 | go func() { |
| 87 | 88 | close(start) |
| 96 | 97 | select { |
| 97 | 98 | case <-done: |
| 98 | 99 | p.Wait() |
| 99 | case <-time.After(100 * time.Millisecond): | |
| 100 | t.Error("Progress didn't stop") | |
| 100 | case <-time.After(150 * time.Millisecond): | |
| 101 | close(fail) | |
| 101 | 102 | } |
| 102 | 103 | }() |
| 103 | 104 | |
| 104 | 105 | <-start |
| 105 | 106 | cancel() |
| 106 | <-shutdown | |
| 107 | select { | |
| 108 | case <-shutdown: | |
| 109 | case <-fail: | |
| 110 | t.Error("Progress didn't shutdown") | |
| 111 | } | |
| 107 | 112 | } |
| 108 | 113 | |
| 109 | 114 | // MaxWidthDistributor shouldn't stuck in the middle while removing or aborting a bar |