captureOutput captures the output of a function call
(f func())
| 274 | |
| 275 | // captureOutput captures the output of a function call |
| 276 | func captureOutput(f func()) string { |
| 277 | var buf bytes.Buffer |
| 278 | stdout := os.Stdout |
| 279 | r, w, _ := os.Pipe() |
| 280 | os.Stdout = w |
| 281 | f() |
| 282 | _ = w.Close() |
| 283 | os.Stdout = stdout |
| 284 | _, _ = buf.ReadFrom(r) |
| 285 | return buf.String() |
| 286 | } |
| 287 | |
| 288 | // captureInput captures the input for a function call |
| 289 | func captureInput(input string) func() { |
no test coverage detected