check bar.Current() in TestBarEnableTriggerCompleteAndIncrementBefore
Vladimir Bauer
2 years ago
| 70 | 70 | p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard)) |
| 71 | 71 | bar := p.AddBar(0) // never complete bar |
| 72 | 72 | |
| 73 | targetTotal := int64(80) | |
| 74 | ||
| 73 | 75 | for _, f := range []func(){ |
| 74 | 76 | func() { bar.SetTotal(40, false) }, |
| 75 | 77 | func() { bar.IncrBy(60) }, |
| 76 | func() { bar.SetTotal(80, false) }, | |
| 78 | func() { bar.SetTotal(targetTotal, false) }, | |
| 77 | 79 | func() { bar.IncrBy(20) }, |
| 78 | 80 | } { |
| 79 | 81 | f() |
| 86 | 88 | |
| 87 | 89 | if !bar.Completed() { |
| 88 | 90 | t.Fail() |
| 91 | } | |
| 92 | ||
| 93 | if current := bar.Current(); current != targetTotal { | |
| 94 | t.Errorf("Expected current: %d, got: %d", targetTotal, current) | |
| 89 | 95 | } |
| 90 | 96 | |
| 91 | 97 | p.Wait() |