TestHelpFlagInHelp checks, if '--help' flag is shown in help for child (executing `parent help child`), that has no other flags. Related to https://github.com/spf13/cobra/issues/302.
(t *testing.T)
| 1090 | // that has no other flags. |
| 1091 | // Related to https://github.com/spf13/cobra/issues/302. |
| 1092 | func TestHelpFlagInHelp(t *testing.T) { |
| 1093 | parentCmd := &Command{Use: "parent", Run: func(*Command, []string) {}} |
| 1094 | |
| 1095 | childCmd := &Command{Use: "child", Run: func(*Command, []string) {}} |
| 1096 | parentCmd.AddCommand(childCmd) |
| 1097 | |
| 1098 | output, err := executeCommand(parentCmd, "help", "child") |
| 1099 | if err != nil { |
| 1100 | t.Errorf("Unexpected error: %v", err) |
| 1101 | } |
| 1102 | |
| 1103 | checkStringContains(t, output, "[flags]") |
| 1104 | } |
| 1105 | |
| 1106 | func TestFlagsInUsage(t *testing.T) { |
| 1107 | rootCmd := &Command{Use: "root", Args: NoArgs, Run: func(*Command, []string) {}} |
nothing calls this directly
no test coverage detected