MCPcopy
hub / github.com/spf13/cobra / TestSubcommandExecuteC

Function TestSubcommandExecuteC

command_test.go:159–175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

157}
158
159func TestSubcommandExecuteC(t *testing.T) {
160 rootCmd := &Command{Use: "root", Run: emptyRun}
161 childCmd := &Command{Use: "child", Run: emptyRun}
162 rootCmd.AddCommand(childCmd)
163
164 c, output, err := executeCommandC(rootCmd, "child")
165 if output != "" {
166 t.Errorf("Unexpected output: %v", output)
167 }
168 if err != nil {
169 t.Errorf("Unexpected error: %v", err)
170 }
171
172 if c.Name() != "child" {
173 t.Errorf(`invalid command returned from ExecuteC: expected "child"', got: %q`, c.Name())
174 }
175}
176
177func TestExecuteContext(t *testing.T) {
178 ctx := context.TODO()

Callers

nothing calls this directly

Calls 3

AddCommandMethod · 0.95
executeCommandCFunction · 0.85
NameMethod · 0.80

Tested by

no test coverage detected