Codebase list golang-github-vbauerster-mpb / fab4434
check bar.Current() in TestBarEnableTriggerCompleteAndIncrementAfter Vladimir Bauer 2 years ago
1 changed file(s) with 9 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
101101 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard))
102102 bar := p.AddBar(0) // never complete bar
103103
104 targetTotal := int64(80)
105
104106 for _, f := range []func(){
105107 func() { bar.SetTotal(40, false) },
106108 func() { bar.IncrBy(60) },
107 func() { bar.SetTotal(80, false) },
108 func() { bar.EnableTriggerComplete() },
109 func() { bar.SetTotal(targetTotal, false) },
110 func() { bar.EnableTriggerComplete() }, // disables any next SetTotal
111 func() { bar.SetTotal(100, true) }, // nop
109112 } {
110113 f()
111114 if bar.Completed() {
117120
118121 if !bar.Completed() {
119122 t.Fail()
123 }
124
125 if current := bar.Current(); current != targetTotal {
126 t.Errorf("Expected current: %d, got: %d", targetTotal, current)
120127 }
121128
122129 p.Wait()