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

Function TestGenRSTNoHiddenParents

doc/rest_docs_test.go:43–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestGenRSTNoHiddenParents(t *testing.T) {
44 // We generate on a subcommand so we have both subcommands and parents
45 for _, name := range []string{"rootflag", "strtwo"} {
46 f := rootCmd.PersistentFlags().Lookup(name)
47 f.Hidden = true
48 defer func() { f.Hidden = false }()
49 }
50 buf := new(bytes.Buffer)
51 if err := GenReST(echoCmd, buf); err != nil {
52 t.Fatal(err)
53 }
54 output := buf.String()
55
56 checkStringContains(t, output, echoCmd.Long)
57 checkStringContains(t, output, echoCmd.Example)
58 checkStringContains(t, output, "boolone")
59 checkStringOmits(t, output, "rootflag")
60 checkStringContains(t, output, rootCmd.Short)
61 checkStringContains(t, output, echoSubCmd.Short)
62 checkStringOmits(t, output, deprecatedCmd.Short)
63 checkStringOmits(t, output, "Options inherited from parent commands")
64}
65
66func TestGenRSTNoTag(t *testing.T) {
67 rootCmd.DisableAutoGenTag = true

Callers

nothing calls this directly

Calls 5

GenReSTFunction · 0.85
PersistentFlagsMethod · 0.80
StringMethod · 0.80
checkStringContainsFunction · 0.70
checkStringOmitsFunction · 0.70

Tested by

no test coverage detected