captureNextOutput runs runNext and captures stdout
(t *testing.T, args []string)
| 149 | |
| 150 | // captureNextOutput runs runNext and captures stdout |
| 151 | func captureNextOutput(t *testing.T, args []string) (string, error) { |
| 152 | t.Helper() |
| 153 | |
| 154 | oldStdout := os.Stdout |
| 155 | r, w, _ := os.Pipe() |
| 156 | os.Stdout = w |
| 157 | |
| 158 | err := runNext(nextCmd, args) |
| 159 | |
| 160 | w.Close() |
| 161 | os.Stdout = oldStdout |
| 162 | |
| 163 | var buf bytes.Buffer |
| 164 | buf.ReadFrom(r) |
| 165 | return buf.String(), err |
| 166 | } |
| 167 | |
| 168 | // resetNextFlags resets all next command flags to defaults |
| 169 | func resetNextFlags() { |
no test coverage detected