execute runs cmd as if it were the root command: it attaches mock to the command context so RunE bodies can pull it via StoreFrom, captures stdout and stderr into one buffer (mirroring how cobra collapses both onto the user's terminal), and silences usage so error output stays minimal. Pass mock ==
(t *testing.T, cmd *cobra.Command, mock store.Store, args ...string)
| 224 | // |
| 225 | // Pass mock == nil for commands that do not consult the store. |
| 226 | func execute(t *testing.T, cmd *cobra.Command, mock store.Store, args ...string) (string, error) { |
| 227 | t.Helper() |
| 228 | return runCobra(t, cmd, mock, nil, args) |
| 229 | } |
| 230 | |
| 231 | func executeWithStdin(t *testing.T, cmd *cobra.Command, mock store.Store, stdin string, args ...string) (string, error) { |
| 232 | t.Helper() |
no test coverage detected