MCPcopy
hub / github.com/cli/cli / TestGenManNoHiddenParents

Function TestGenManNoHiddenParents

internal/docs/man_test.go:48–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func 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
83func TestGenManSeeAlso(t *testing.T) {
84 rootCmd := &cobra.Command{Use: "root", Run: emptyRun}

Callers

nothing calls this directly

Calls 7

renderManFunction · 0.85
translateFunction · 0.85
checkStringContainsFunction · 0.85
checkStringOmitsFunction · 0.85
ReplaceMethod · 0.80
NameMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected