| 1 | package cli_test |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestMan(t *testing.T) { |
| 9 | stdout, _, err := runDaselCmd([]string{"man"}) |
| 10 | if err != nil { |
| 11 | t.Fatalf("unexpected error: %v", err) |
| 12 | } |
| 13 | if stdout == "" { |
| 14 | t.Fatal("expected non-empty output") |
| 15 | } |
| 16 | |
| 17 | // Roff directives |
| 18 | if !strings.Contains(stdout, ".TH") { |
| 19 | t.Error("expected output to contain .TH roff directive") |
| 20 | } |
| 21 | if !strings.Contains(stdout, ".SH") { |
| 22 | t.Error("expected output to contain .SH roff directive") |
| 23 | } |
| 24 | |
| 25 | // Description |
| 26 | if !strings.Contains(stdout, "Query and modify data structures") { |
| 27 | t.Error("expected output to contain description text") |
| 28 | } |
| 29 | |
| 30 | // Subcommands |
| 31 | for _, sub := range []string{"query", "version", "completion", "man"} { |
| 32 | if !strings.Contains(stdout, sub) { |
| 33 | t.Errorf("expected output to contain subcommand %q", sub) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // Key flags (roff uses \- for dashes) |
| 38 | for _, flag := range []string{"in", "out", "compact"} { |
| 39 | if !strings.Contains(stdout, flag) { |
| 40 | t.Errorf("expected output to contain flag %q", flag) |
| 41 | } |
| 42 | } |
| 43 | } |