Codebase list golang-github-vbauerster-mpb / de4e3ab
check bar.Current() in TestBarEnableTriggerCompleteAndIncrementBefore Vladimir Bauer 2 years ago
1 changed file(s) with 7 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
7070 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard))
7171 bar := p.AddBar(0) // never complete bar
7272
73 targetTotal := int64(80)
74
7375 for _, f := range []func(){
7476 func() { bar.SetTotal(40, false) },
7577 func() { bar.IncrBy(60) },
76 func() { bar.SetTotal(80, false) },
78 func() { bar.SetTotal(targetTotal, false) },
7779 func() { bar.IncrBy(20) },
7880 } {
7981 f()
8688
8789 if !bar.Completed() {
8890 t.Fail()
91 }
92
93 if current := bar.Current(); current != targetTotal {
94 t.Errorf("Expected current: %d, got: %d", targetTotal, current)
8995 }
9096
9197 p.Wait()