execute runs the App once with the given args and returns the captured streams + exit code. Tests share this helper so changes to App.Run flow only need to be applied in one place.
(t *testing.T, args ...string)
| 16 | // streams + exit code. Tests share this helper so changes to App.Run flow |
| 17 | // only need to be applied in one place. |
| 18 | func execute(t *testing.T, args ...string) (stdout string, stderr string, code int) { |
| 19 | t.Helper() |
| 20 | var out, err bytes.Buffer |
| 21 | app := cli.New(cli.Options{ |
| 22 | Version: "test-version", |
| 23 | Stdout: &out, |
| 24 | Stderr: &err, |
| 25 | Stdin: &bytes.Buffer{}, |
| 26 | }) |
| 27 | code = app.Run(args) |
| 28 | return out.String(), err.String(), code |
| 29 | } |
| 30 | |
| 31 | // writeTempFile creates a file inside a t.TempDir with the given content and |
| 32 | // returns its absolute path. Used by `add`-style command tests that need a |
no test coverage detected