diff --git a/decorators_test.go b/decorators_test.go index 390103e..5614556 100644 --- a/decorators_test.go +++ b/decorators_test.go @@ -309,3 +309,45 @@ t.Errorf("%q not found in bar: %s\n", want, barOut) } } + +func TestAppendETA(t *testing.T) { + var buf bytes.Buffer + p := mpb.New().SetOut(&buf) + + bar := p.AddBar(100).TrimLeftSpace().TrimRightSpace(). + AppendETA(0, 0) + + for i := 0; i < 100; i++ { + time.Sleep(10 * time.Millisecond) + bar.Incr(1) + } + + p.Stop() + + want := "]0s" + barOut := buf.String() + if !strings.Contains(barOut, want) { + t.Errorf("%q not found in bar: %s\n", want, barOut) + } +} + +func TestAppendETADindentRight(t *testing.T) { + var buf bytes.Buffer + p := mpb.New().SetOut(&buf) + + bar := p.AddBar(100).TrimLeftSpace().TrimRightSpace(). + AppendETA(3, mpb.DidentRight) + + for i := 0; i < 100; i++ { + time.Sleep(10 * time.Millisecond) + bar.Incr(1) + } + + p.Stop() + + want := "]0s " + barOut := buf.String() + if !strings.Contains(barOut, want) { + t.Errorf("%q not found in bar: %s\n", want, barOut) + } +}