MCPcopy
hub / github.com/cli/cli / TestGenMdNoHiddenParents

Function TestGenMdNoHiddenParents

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

Source from the content-addressed store, hash-verified

46}
47
48func TestGenMdNoHiddenParents(t *testing.T) {
49 linkHandler := func(s string) string { return s }
50
51 // We generate on subcommand so we have both subcommands and parents.
52 for _, name := range []string{"rootflag", "strtwo"} {
53 f := rootCmd.PersistentFlags().Lookup(name)
54 f.Hidden = true
55 defer func() { f.Hidden = false }()
56 }
57 buf := new(bytes.Buffer)
58 if err := genMarkdownCustom(echoCmd, buf, linkHandler); err != nil {
59 t.Fatal(err)
60 }
61 output := buf.String()
62
63 checkStringContains(t, output, echoCmd.Long)
64 checkStringContains(t, output, echoCmd.Example)
65 checkStringContains(t, output, "boolone")
66 checkStringOmits(t, output, "rootflag")
67 checkStringOmits(t, output, rootCmd.Short)
68 checkStringOmits(t, output, echoSubCmd.Short)
69 checkStringOmits(t, output, deprecatedCmd.Short)
70 checkStringOmits(t, output, "Options inherited from parent commands")
71}
72
73func TestGenMdAliases(t *testing.T) {
74 buf := new(bytes.Buffer)

Callers

nothing calls this directly

Calls 4

genMarkdownCustomFunction · 0.85
checkStringContainsFunction · 0.85
checkStringOmitsFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected