18 lines
266 B
Go
18 lines
266 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCaptureOutput(t *testing.T) {
|
|
result := CaptureOutput(func() {
|
|
fmt.Fprint(os.Stdout, "foo")
|
|
fmt.Fprint(os.Stderr, "bar")
|
|
})
|
|
|
|
assert.Equal(t, "foobar", result)
|
|
}
|