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

Function TestHelpFlagExecutedOnChild

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

Source from the content-addressed store, hash-verified

1073}
1074
1075func TestHelpFlagExecutedOnChild(t *testing.T) {
1076 rootCmd := &Command{Use: "root", Run: emptyRun}
1077 childCmd := &Command{Use: "child", Long: "Long description", Run: emptyRun}
1078 rootCmd.AddCommand(childCmd)
1079
1080 output, err := executeCommand(rootCmd, "child", "--help")
1081 if err != nil {
1082 t.Errorf("Unexpected error: %v", err)
1083 }
1084
1085 checkStringContains(t, output, childCmd.Long)
1086}
1087
1088// TestHelpFlagInHelp checks,
1089// if '--help' flag is shown in help for child (executing `parent help child`),

Callers

nothing calls this directly

Calls 3

AddCommandMethod · 0.95
executeCommandFunction · 0.85
checkStringContainsFunction · 0.70

Tested by

no test coverage detected