(t *testing.T)
| 37 | } |
| 38 | |
| 39 | func TestGenManDoc(t *testing.T) { |
| 40 | header := &GenManHeader{ |
| 41 | Title: "Project", |
| 42 | Section: "2", |
| 43 | } |
| 44 | |
| 45 | // We generate on a subcommand so we have both subcommands and parents |
| 46 | buf := new(bytes.Buffer) |
| 47 | if err := GenMan(echoCmd, header, buf); err != nil { |
| 48 | t.Fatal(err) |
| 49 | } |
| 50 | output := buf.String() |
| 51 | |
| 52 | // Make sure parent has - in CommandPath() in SEE ALSO: |
| 53 | parentPath := echoCmd.Parent().CommandPath() |
| 54 | dashParentPath := strings.ReplaceAll(parentPath, " ", "-") |
| 55 | expected := translate(dashParentPath) |
| 56 | expected = expected + "(" + header.Section + ")" |
| 57 | checkStringContains(t, output, expected) |
| 58 | |
| 59 | checkStringContains(t, output, translate(echoCmd.Name())) |
| 60 | checkStringContains(t, output, translate(echoCmd.Name())) |
| 61 | checkStringContains(t, output, "boolone") |
| 62 | checkStringContains(t, output, "rootflag") |
| 63 | checkStringContains(t, output, translate(rootCmd.Name())) |
| 64 | checkStringContains(t, output, translate(echoSubCmd.Name())) |
| 65 | checkStringOmits(t, output, translate(deprecatedCmd.Name())) |
| 66 | checkStringContains(t, output, translate("Auto generated")) |
| 67 | } |
| 68 | |
| 69 | func TestGenManNoHiddenParents(t *testing.T) { |
| 70 | header := &GenManHeader{ |
nothing calls this directly
no test coverage detected