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

Function TestGenManNoHiddenParents

doc/man_docs_test.go:69–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func 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
105func TestGenManNoGenTag(t *testing.T) {
106 echoCmd.DisableAutoGenTag = true

Callers

nothing calls this directly

Calls 9

GenManFunction · 0.85
translateFunction · 0.85
PersistentFlagsMethod · 0.80
StringMethod · 0.80
CommandPathMethod · 0.80
ParentMethod · 0.80
NameMethod · 0.80
checkStringContainsFunction · 0.70
checkStringOmitsFunction · 0.70

Tested by

no test coverage detected