From 7d9b39a3038784105442bfd1a50aa44482830fb5 Mon Sep 17 00:00:00 2001 From: Vladimir Bauer Date: Sun, 5 Mar 2023 23:26:50 +0500 Subject: [PATCH] TestBarSetTotal --- bar_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bar_test.go b/bar_test.go index ca715135..db25d503 100644 --- a/bar_test.go +++ b/bar_test.go @@ -50,6 +50,23 @@ func TestBarAborted(t *testing.T) { p.Wait() } +func TestBarSetTotal(t *testing.T) { + p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard)) + bar := p.AddBar(0) + + bar.SetTotal(0, false) + if bar.Completed() { + t.Error("expected bar not to complete") + } + + bar.SetTotal(0, true) + if !bar.Completed() { + t.Error("expected bar to complete") + } + + p.Wait() +} + func TestBarEnableTriggerCompleteAndIncrementBefore(t *testing.T) { p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard)) bar := p.AddBar(0) // never complete bar