Codebase list golang-github-vbauerster-mpb / 2577bff
WithBarRemoveOnComplete test Vladimir Bauer 7 years ago
1 changed file(s) with 27 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
99 "time"
1010 "unicode/utf8"
1111
12 "github.com/vbauerster/mpb"
1213 . "github.com/vbauerster/mpb/v4"
1314 "github.com/vbauerster/mpb/v4/decor"
1415 )
8788 }
8889 }
8990
90 func TestBarHas100PercentAfterOnComplete(t *testing.T) {
91 func TestBarHas100PercentWithOnCompleteDecorator(t *testing.T) {
9192 var buf bytes.Buffer
9293
9394 p := New(WithOutput(&buf))
100101 decor.Percentage(), "done",
101102 ),
102103 ),
104 )
105
106 for i := 0; i < total; i++ {
107 bar.Increment()
108 time.Sleep(10 * time.Millisecond)
109 }
110
111 p.Wait()
112
113 hundred := "100 %"
114 if !bytes.Contains(buf.Bytes(), []byte(hundred)) {
115 t.Errorf("Bar's buffer does not contain: %q\n", hundred)
116 }
117 }
118
119 func TestBarHas100PercentWithBarRemoveOnComplete(t *testing.T) {
120 var buf bytes.Buffer
121
122 p := New(WithOutput(&buf))
123
124 total := 50
125
126 bar := p.AddBar(int64(total),
127 mpb.BarRemoveOnComplete(),
128 AppendDecorators(decor.Percentage()),
103129 )
104130
105131 for i := 0; i < total; i++ {