Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tothszabi committed Dec 6, 2023
1 parent a0e03da commit a89ea8c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions progress/wrapper_test.go
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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)
}

0 comments on commit a89ea8c

Please sign in to comment.