(args []string)
| 70 | } |
| 71 | |
| 72 | func invokeCommand(args []string) (*cobra.Command, *internal.ToolboxOptions, string, error) { |
| 73 | buf := new(bytes.Buffer) |
| 74 | opts := internal.NewToolboxOptions(internal.WithIOStreams(buf, buf)) |
| 75 | c := NewCommand(opts) |
| 76 | |
| 77 | // Keep the test output quiet |
| 78 | c.SilenceUsage = true |
| 79 | c.SilenceErrors = true |
| 80 | |
| 81 | // Capture output |
| 82 | c.SetOut(buf) |
| 83 | c.SetErr(buf) |
| 84 | c.SetArgs(args) |
| 85 | |
| 86 | // Disable execute behavior |
| 87 | c.RunE = func(*cobra.Command, []string) error { |
| 88 | return nil |
| 89 | } |
| 90 | |
| 91 | err := c.Execute() |
| 92 | |
| 93 | return c, opts, buf.String(), err |
| 94 | } |
| 95 | |
| 96 | // invokeCommandWithContext executes the command with a context and returns the captured output. |
| 97 | func invokeCommandWithContext(ctx context.Context, args []string) (*cobra.Command, *internal.ToolboxOptions, string, error) { |
no test coverage detected