(t *testing.T)
| 17 | } |
| 18 | |
| 19 | func 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 | |
| 48 | func TestGenManNoHiddenParents(t *testing.T) { |
| 49 | header := &GenManHeader{ |
nothing calls this directly
no test coverage detected