Codebase list golang-github-vbauerster-mpb / 843b958
TestPrependETA Vladimir Bauer 9 years ago
1 changed file(s) with 42 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
266266 t.Errorf("%q not found in bar: %s\n", want, barOut)
267267 }
268268 }
269
270 func TestPrependETA(t *testing.T) {
271 var buf bytes.Buffer
272 p := mpb.New().SetOut(&buf)
273
274 bar := p.AddBar(100).TrimLeftSpace().TrimRightSpace().
275 PrependETA(0, 0)
276
277 for i := 0; i < 100; i++ {
278 time.Sleep(10 * time.Millisecond)
279 bar.Incr(1)
280 }
281
282 p.Stop()
283
284 want := "0s["
285 barOut := buf.String()
286 if !strings.Contains(barOut, want) {
287 t.Errorf("%q not found in bar: %s\n", want, barOut)
288 }
289 }
290
291 func TestPrependETADindentRight(t *testing.T) {
292 var buf bytes.Buffer
293 p := mpb.New().SetOut(&buf)
294
295 bar := p.AddBar(100).TrimLeftSpace().TrimRightSpace().
296 PrependETA(3, mpb.DidentRight)
297
298 for i := 0; i < 100; i++ {
299 time.Sleep(10 * time.Millisecond)
300 bar.Incr(1)
301 }
302
303 p.Stop()
304
305 want := "0s ["
306 barOut := buf.String()
307 if !strings.Contains(barOut, want) {
308 t.Errorf("%q not found in bar: %s\n", want, barOut)
309 }
310 }