Files
helmfile/pkg/testutil/testutil_test.go
yxxhero df01973824 cleanup: remove panic in testutil (#890)
* cleanup: remove panic in testutil

Signed-off-by: yxxhero <aiopsclub@163.com>
2023-06-13 13:44:32 +08:00

44 lines
672 B
Go

package testutil
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
// TestCaptureStdout tests the CaptureStdout function.
func TestCaptureStdout(t *testing.T) {
tests := []struct {
output string
expected string
}{
{
output: "123",
expected: "123",
},
{
output: "test",
expected: "test",
},
{
output: "",
expected: "",
},
{
output: "...",
expected: "...",
},
}
for _, test := range tests {
result, err := CaptureStdout(func() {
fmt.Print(test.output)
})
assert.NoError(t, err)
if result != test.expected {
t.Errorf("CaptureStdout() = %v, want %v", result, test.expected)
}
}
}