MCPcopy Create free account
hub / github.com/driangle/taskmd / TestTemplatesList_JSONFormat

Function TestTemplatesList_JSONFormat

apps/cli/internal/cli/templates_cmd_test.go:66–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func 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
98func TestTemplatesList_YAMLFormat(t *testing.T) {
99 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 3

resetTemplatesFlagsFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected