diff --git a/progress/wrapper_test.go b/progress/wrapper_test.go index 2ba1acc..ffb656d 100644 --- a/progress/wrapper_test.go +++ b/progress/wrapper_test.go @@ -1,10 +1,16 @@ +//go:build !race // +build !race package progress import ( + "bytes" + "fmt" + "io" "testing" "time" + + "github.com/stretchr/testify/assert" ) func TestNewWrapper(t *testing.T) { @@ -23,3 +29,16 @@ func TestNewDefaultWrapper(t *testing.T) { time.Sleep(2 * time.Second) }) } + +func TestNewDefaultWrapperWithOutput(t *testing.T) { + message := "loading" + + var b bytes.Buffer + NewDefaultWrapperWithOutput(message, io.Writer(&b)).WrapAction(func() { + time.Sleep(2 * time.Second) + }) + + expected := fmt.Sprintf("%s...\n", message) + got := b.String() + assert.Equal(t, expected, got) +}