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

Function TestAdd_JSONOutput

apps/cli/internal/cli/add_test.go:187–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

185}
186
187func TestAdd_JSONOutput(t *testing.T) {
188 tmpDir := t.TempDir()
189 resetAddFlags()
190 taskDir = tmpDir
191 addFormat = "json"
192
193 output, err := captureAddOutput(t, "JSON task")
194 if err != nil {
195 t.Fatalf("unexpected error: %v", err)
196 }
197
198 var result addResult
199 if err := json.Unmarshal([]byte(output), &result); err != nil {
200 t.Fatalf("failed to parse JSON output: %v\nOutput: %s", err, output)
201 }
202
203 if result.ID != "001" {
204 t.Errorf("expected id 001, got %s", result.ID)
205 }
206 if result.Title != "JSON task" {
207 t.Errorf("expected title 'JSON task', got %s", result.Title)
208 }
209 if result.Status != "pending" {
210 t.Errorf("expected status pending, got %s", result.Status)
211 }
212 if result.Priority != "medium" {
213 t.Errorf("expected priority medium, got %s", result.Priority)
214 }
215 if result.FilePath == "" {
216 t.Error("expected non-empty file_path")
217 }
218}
219
220func TestAdd_InvalidPriority(t *testing.T) {
221 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 3

resetAddFlagsFunction · 0.85
captureAddOutputFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected