2019-05-06 23:18:10 +02:00
|
|
|
package util
|
2018-11-17 13:57:19 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2019-05-03 18:57:28 +02:00
|
|
|
func TestCaptureOutput(t *testing.T) {
|
|
|
|
result := CaptureOutput(func() {
|
2018-11-17 13:57:19 +01:00
|
|
|
fmt.Fprint(os.Stdout, "foo")
|
|
|
|
fmt.Fprint(os.Stderr, "bar")
|
|
|
|
})
|
|
|
|
|
|
|
|
assert.Equal(t, "foobar", result)
|
|
|
|
}
|