Codebase list golang-github-vbauerster-mpb / 491ccba
add ForceAutoRefresh opt to tests that were relying on auto refresh Vladimir Bauer 3 years ago
1 changed file(s) with 29 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
117117
118118 func TestBarSetRefill(t *testing.T) {
119119 var buf bytes.Buffer
120
121 p := mpb.New(mpb.WithOutput(&buf), mpb.WithWidth(100))
120 p := mpb.New(
121 mpb.WithWidth(100),
122 mpb.WithOutput(&buf),
123 mpb.ForceAutoRefresh(),
124 )
122125
123126 total := 100
124127 till := 30
146149
147150 func TestBarHas100PercentWithBarRemoveOnComplete(t *testing.T) {
148151 var buf bytes.Buffer
149
150 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(&buf))
152 p := mpb.New(
153 mpb.WithWidth(80),
154 mpb.WithOutput(&buf),
155 mpb.ForceAutoRefresh(),
156 )
151157
152158 total := 50
153159
171177 customFormat := "╢▌▌░╟"
172178 runes := []rune(customFormat)
173179 total := 80
174 p := mpb.New(mpb.WithWidth(total), mpb.WithOutput(&buf))
180 p := mpb.New(
181 mpb.WithWidth(80),
182 mpb.WithOutput(&buf),
183 mpb.ForceAutoRefresh(),
184 )
175185 bs := mpb.BarStyle()
176186 bs.Lbound(string(runes[0]))
177187 bs.Filler(string(runes[1]))
246256 ctx, cancel := context.WithCancel(context.Background())
247257 p := mpb.NewWithContext(ctx,
248258 mpb.WithOutput(io.Discard),
259 mpb.ForceAutoRefresh(),
249260 mpb.WithShutdownNotifier(shutdown),
250261 )
251 b := p.AddBar(100)
252 q := p.AddBar(100, mpb.BarQueueAfter(b))
253
254 b.IncrBy(100)
255 b.Wait()
262 a := p.AddBar(100)
263 b := p.AddBar(100, mpb.BarQueueAfter(a))
264 identity := map[*mpb.Bar]string{
265 a: "a",
266 b: "b",
267 }
268
269 a.IncrBy(100)
270 a.Wait()
256271 cancel()
257272
258273 bars := (<-shutdown).([]*mpb.Bar)
261276 }
262277
263278 p.Wait()
264 if bars[0] != q {
265 t.Errorf("Expected bars[0]: %p, got: %p", q, bars[0])
266 }
267 }
279 if bars[0] != b {
280 t.Errorf("Expected bars[0] == b, got: %s", identity[bars[0]])
281 }
282 }