(t *testing.T)
| 67 | } |
| 68 | |
| 69 | func TestGenManNoHiddenParents(t *testing.T) { |
| 70 | header := &GenManHeader{ |
| 71 | Title: "Project", |
| 72 | Section: "2", |
| 73 | } |
| 74 | |
| 75 | // We generate on a subcommand so we have both subcommands and parents |
| 76 | for _, name := range []string{"rootflag", "strtwo"} { |
| 77 | f := rootCmd.PersistentFlags().Lookup(name) |
| 78 | f.Hidden = true |
| 79 | defer func() { f.Hidden = false }() |
| 80 | } |
| 81 | buf := new(bytes.Buffer) |
| 82 | if err := GenMan(echoCmd, header, buf); err != nil { |
| 83 | t.Fatal(err) |
| 84 | } |
| 85 | output := buf.String() |
| 86 | |
| 87 | // Make sure parent has - in CommandPath() in SEE ALSO: |
| 88 | parentPath := echoCmd.Parent().CommandPath() |
| 89 | dashParentPath := strings.ReplaceAll(parentPath, " ", "-") |
| 90 | expected := translate(dashParentPath) |
| 91 | expected = expected + "(" + header.Section + ")" |
| 92 | checkStringContains(t, output, expected) |
| 93 | |
| 94 | checkStringContains(t, output, translate(echoCmd.Name())) |
| 95 | checkStringContains(t, output, translate(echoCmd.Name())) |
| 96 | checkStringContains(t, output, "boolone") |
| 97 | checkStringOmits(t, output, "rootflag") |
| 98 | checkStringContains(t, output, translate(rootCmd.Name())) |
| 99 | checkStringContains(t, output, translate(echoSubCmd.Name())) |
| 100 | checkStringOmits(t, output, translate(deprecatedCmd.Name())) |
| 101 | checkStringContains(t, output, translate("Auto generated")) |
| 102 | checkStringOmits(t, output, "OPTIONS INHERITED FROM PARENT COMMANDS") |
| 103 | } |
| 104 | |
| 105 | func TestGenManNoGenTag(t *testing.T) { |
| 106 | echoCmd.DisableAutoGenTag = true |
nothing calls this directly
no test coverage detected