Skip to content

Commit

Permalink
check bar.Current() in TestBarEnableTriggerCompleteAndIncrementAfter
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Oct 7, 2023
1 parent de4e3ab commit fab4434
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ func TestBarEnableTriggerCompleteAndIncrementAfter(t *testing.T) {
p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard))
bar := p.AddBar(0) // never complete bar

targetTotal := int64(80)

for _, f := range []func(){
func() { bar.SetTotal(40, false) },
func() { bar.IncrBy(60) },
func() { bar.SetTotal(80, false) },
func() { bar.EnableTriggerComplete() },
func() { bar.SetTotal(targetTotal, false) },
func() { bar.EnableTriggerComplete() }, // disables any next SetTotal
func() { bar.SetTotal(100, true) }, // nop
} {
f()
if bar.Completed() {
Expand All @@ -120,6 +123,10 @@ func TestBarEnableTriggerCompleteAndIncrementAfter(t *testing.T) {
t.Fail()
}

if current := bar.Current(); current != targetTotal {
t.Errorf("Expected current: %d, got: %d", targetTotal, current)
}

p.Wait()
}

Expand Down

0 comments on commit fab4434

Please sign in to comment.