(t *testing.T)
| 64 | } |
| 65 | |
| 66 | func TestTemplatesList_JSONFormat(t *testing.T) { |
| 67 | tmpDir := t.TempDir() |
| 68 | resetTemplatesFlags() |
| 69 | taskDir = tmpDir |
| 70 | templatesFormat = "json" |
| 71 | |
| 72 | output, err := captureTemplatesListOutput(t) |
| 73 | if err != nil { |
| 74 | t.Fatalf("unexpected error: %v", err) |
| 75 | } |
| 76 | |
| 77 | var items []templateListItem |
| 78 | if err := json.Unmarshal([]byte(output), &items); err != nil { |
| 79 | t.Fatalf("failed to parse JSON: %v\nOutput: %s", err, output) |
| 80 | } |
| 81 | |
| 82 | if len(items) < 3 { |
| 83 | t.Fatalf("expected at least 3 templates, got %d", len(items)) |
| 84 | } |
| 85 | |
| 86 | names := make(map[string]bool) |
| 87 | for _, item := range items { |
| 88 | names[item.Name] = true |
| 89 | if item.Source == "" { |
| 90 | t.Error("expected non-empty source") |
| 91 | } |
| 92 | } |
| 93 | if !names["feature"] || !names["bug"] || !names["chore"] { |
| 94 | t.Error("expected feature, bug, and chore templates") |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | func TestTemplatesList_YAMLFormat(t *testing.T) { |
| 99 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected