(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func TestGenManNoHiddenParents(t *testing.T) { |
| 49 | header := &GenManHeader{ |
| 50 | Title: "Project", |
| 51 | Section: "1", |
| 52 | } |
| 53 | |
| 54 | // We generate on a subcommand so we have both subcommands and parents |
| 55 | for _, name := range []string{"rootflag", "strtwo"} { |
| 56 | f := rootCmd.PersistentFlags().Lookup(name) |
| 57 | f.Hidden = true |
| 58 | defer func() { f.Hidden = false }() |
| 59 | } |
| 60 | buf := new(bytes.Buffer) |
| 61 | if err := renderMan(echoCmd, header, buf); err != nil { |
| 62 | t.Fatal(err) |
| 63 | } |
| 64 | output := buf.String() |
| 65 | |
| 66 | // Make sure parent has - in CommandPath() in SEE ALSO: |
| 67 | parentPath := echoCmd.Parent().CommandPath() |
| 68 | dashParentPath := strings.Replace(parentPath, " ", "-", -1) |
| 69 | expected := translate(dashParentPath) |
| 70 | expected = expected + "(" + header.Section + ")" |
| 71 | checkStringContains(t, output, expected) |
| 72 | |
| 73 | checkStringContains(t, output, translate(echoCmd.Name())) |
| 74 | checkStringContains(t, output, translate(echoCmd.Name())) |
| 75 | checkStringContains(t, output, "boolone") |
| 76 | checkStringOmits(t, output, "rootflag") |
| 77 | checkStringContains(t, output, translate(rootCmd.Name())) |
| 78 | checkStringContains(t, output, translate(echoSubCmd.Name())) |
| 79 | checkStringOmits(t, output, translate(deprecatedCmd.Name())) |
| 80 | checkStringOmits(t, output, "OPTIONS INHERITED FROM PARENT COMMANDS") |
| 81 | } |
| 82 | |
| 83 | func TestGenManSeeAlso(t *testing.T) { |
| 84 | rootCmd := &cobra.Command{Use: "root", Run: emptyRun} |
nothing calls this directly
no test coverage detected