mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-22 10:53:15 +02:00
mv captureStdout as public func
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// 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 := CaptureStdout(func() {
|
||||
fmt.Print(test.output)
|
||||
})
|
||||
if result != test.expected {
|
||||
t.Errorf("CaptureStdout() = %v, want %v", result, test.expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user