19 lines
254 B
Go
19 lines
254 B
Go
|
package test
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestCapture(t *testing.T) {
|
||
|
result := Capture(func() {
|
||
|
fmt.Fprint(os.Stdout, "foo")
|
||
|
fmt.Fprint(os.Stderr, "bar")
|
||
|
})
|
||
|
|
||
|
assert.Equal(t, "foobar", result)
|
||
|
}
|