Tests: Add pkg/capture/capture_test.go #5330

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-11-22 16:23:47 +01:00
parent ed96f381b9
commit 0e6328a33d

View File

@@ -0,0 +1,22 @@
package capture
import (
"fmt"
"os"
"testing"
)
func TestOutputMergesStdoutAndStderr(t *testing.T) {
got := Output(func() {
fmt.Print("out")
fmt.Fprint(stderrWriter(), "err") // write directly to stderr
})
if got != "outerr" {
t.Fatalf("unexpected combined output: %q", got)
}
}
// stderrWriter returns the current process stderr; split for test clarity.
func stderrWriter() *os.File {
return os.Stderr
}