Documentation
¶
Overview ¶
Package testutil provides shared test helpers for the go-bricks-openapi tool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureStdout ¶
CaptureStdout runs fn with os.Stdout redirected to a pipe and returns what was printed there. Several subcommands write progress via fmt.Printf (os.Stdout), which cobra's SetOut does not intercept, so capturing the real os.Stdout is the only way to observe that output in tests.
The pipe is drained in a goroutine so a large write can't deadlock; the write end is closed even if fn panics (so the drain goroutine reaches EOF and terminates instead of leaking), and the read end is closed once drained (no fd leak).
NOTE: mutates the global os.Stdout; do not call from parallel tests.
Types ¶
This section is empty.