diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-08 08:41:59 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-08 08:41:59 +0200 |
| commit | aa733f9a86b02d7b4d6edd8022a44e4ba417b24c (patch) | |
| tree | efdea87ad377557bb222e948894b5db5832ce6e9 /internal/testutil | |
| parent | 3a255c0c64f858d5c05797aba9a6d159b0c7d82f (diff) | |
test(task-374): fix errcheck issues in tests and support code
Diffstat (limited to 'internal/testutil')
| -rw-r--r-- | internal/testutil/helpers.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/internal/testutil/helpers.go b/internal/testutil/helpers.go index 8f82a9e..08e03a5 100644 --- a/internal/testutil/helpers.go +++ b/internal/testutil/helpers.go @@ -189,8 +189,14 @@ func CaptureOutput(t *testing.T, f func()) (stdout, stderr string) { oldStderr := os.Stderr // Create pipes - rOut, wOut, _ := os.Pipe() - rErr, wErr, _ := os.Pipe() + rOut, wOut, err := os.Pipe() + if err != nil { + t.Fatalf("failed to create stdout pipe: %v", err) + } + rErr, wErr, err := os.Pipe() + if err != nil { + t.Fatalf("failed to create stderr pipe: %v", err) + } // Redirect stdout/stderr os.Stdout = wOut @@ -200,8 +206,12 @@ func CaptureOutput(t *testing.T, f func()) (stdout, stderr string) { f() // Close writers - wOut.Close() - wErr.Close() + if err := wOut.Close(); err != nil { + t.Fatalf("failed to close stdout writer: %v", err) + } + if err := wErr.Close(); err != nil { + t.Fatalf("failed to close stderr writer: %v", err) + } // Read output outBytes := make([]byte, 1024) |
