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

Function TestGenManDoc

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

Source from the content-addressed store, hash-verified

37}
38
39func TestGenManDoc(t *testing.T) {
40 header := &GenManHeader{
41 Title: "Project",
42 Section: "2",
43 }
44
45 // We generate on a subcommand so we have both subcommands and parents
46 buf := new(bytes.Buffer)
47 if err := GenMan(echoCmd, header, buf); err != nil {
48 t.Fatal(err)
49 }
50 output := buf.String()
51
52 // Make sure parent has - in CommandPath() in SEE ALSO:
53 parentPath := echoCmd.Parent().CommandPath()
54 dashParentPath := strings.ReplaceAll(parentPath, " ", "-")
55 expected := translate(dashParentPath)
56 expected = expected + "(" + header.Section + ")"
57 checkStringContains(t, output, expected)
58
59 checkStringContains(t, output, translate(echoCmd.Name()))
60 checkStringContains(t, output, translate(echoCmd.Name()))
61 checkStringContains(t, output, "boolone")
62 checkStringContains(t, output, "rootflag")
63 checkStringContains(t, output, translate(rootCmd.Name()))
64 checkStringContains(t, output, translate(echoSubCmd.Name()))
65 checkStringOmits(t, output, translate(deprecatedCmd.Name()))
66 checkStringContains(t, output, translate("Auto generated"))
67}
68
69func TestGenManNoHiddenParents(t *testing.T) {
70 header := &GenManHeader{

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected