MCPcopy
hub / github.com/cli/cli / TestGenManDoc

Function TestGenManDoc

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

Source from the content-addressed store, hash-verified

17}
18
19func TestGenManDoc(t *testing.T) {
20 header := &GenManHeader{
21 Title: "Project",
22 Section: "1",
23 }
24
25 // We generate on a subcommand so we have both subcommands and parents
26 buf := new(bytes.Buffer)
27 if err := renderMan(echoCmd, header, buf); err != nil {
28 t.Fatal(err)
29 }
30 output := buf.String()
31
32 // Make sure parent has - in CommandPath() in SEE ALSO:
33 parentPath := echoCmd.Parent().CommandPath()
34 dashParentPath := strings.Replace(parentPath, " ", "-", -1)
35 expected := translate(dashParentPath)
36 expected = expected + "(" + header.Section + ")"
37 checkStringContains(t, output, expected)
38
39 checkStringContains(t, output, translate(echoCmd.Name()))
40 checkStringContains(t, output, translate(echoCmd.Name()))
41 checkStringContains(t, output, "boolone")
42 checkStringContains(t, output, "rootflag")
43 checkStringContains(t, output, translate(rootCmd.Name()))
44 checkStringContains(t, output, translate(echoSubCmd.Name()))
45 checkStringOmits(t, output, translate(deprecatedCmd.Name()))
46}
47
48func TestGenManNoHiddenParents(t *testing.T) {
49 header := &GenManHeader{

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