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

Function TestHelpCommandExecutedOnChild

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

Source from the content-addressed store, hash-verified

951}
952
953func TestHelpCommandExecutedOnChild(t *testing.T) {
954 rootCmd := &Command{Use: "root", Run: emptyRun}
955 childCmd := &Command{Use: "child", Long: "Long description", Run: emptyRun}
956 rootCmd.AddCommand(childCmd)
957
958 output, err := executeCommand(rootCmd, "help", "child")
959 if err != nil {
960 t.Errorf("Unexpected error: %v", err)
961 }
962
963 checkStringContains(t, output, childCmd.Long)
964}
965
966func TestHelpCommandExecutedOnChildWithFlagThatShadowsParentFlag(t *testing.T) {
967 parent := &Command{Use: "parent", Run: emptyRun}

Callers

nothing calls this directly

Calls 3

AddCommandMethod · 0.95
executeCommandFunction · 0.85
checkStringContainsFunction · 0.70

Tested by

no test coverage detected