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

Function TestGenManSeeAlso

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

Source from the content-addressed store, hash-verified

125}
126
127func TestGenManSeeAlso(t *testing.T) {
128 rootCmd := &cobra.Command{Use: "root", Run: emptyRun}
129 aCmd := &cobra.Command{Use: "aaa", Run: emptyRun, Hidden: true} // #229
130 bCmd := &cobra.Command{Use: "bbb", Run: emptyRun}
131 cCmd := &cobra.Command{Use: "ccc", Run: emptyRun}
132 rootCmd.AddCommand(aCmd, bCmd, cCmd)
133
134 buf := new(bytes.Buffer)
135 header := &GenManHeader{}
136 if err := GenMan(rootCmd, header, buf); err != nil {
137 t.Fatal(err)
138 }
139 scanner := bufio.NewScanner(buf)
140
141 if err := assertLineFound(scanner, ".SH SEE ALSO"); err != nil {
142 t.Fatalf("Couldn't find SEE ALSO section header: %v", err)
143 }
144 if err := assertNextLineEquals(scanner, `\fBroot-bbb(1)\fP, \fBroot-ccc(1)\fP`); err != nil {
145 t.Fatalf("Second line after SEE ALSO wasn't correct: %v", err)
146 }
147}
148
149func TestManPrintFlagsHidesShortDeprecated(t *testing.T) {
150 c := &cobra.Command{}

Callers

nothing calls this directly

Calls 4

AddCommandMethod · 0.95
GenManFunction · 0.85
assertLineFoundFunction · 0.85
assertNextLineEqualsFunction · 0.85

Tested by

no test coverage detected