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

Function TestDeduplicate_JSONFormat

apps/cli/internal/cli/deduplicate_test.go:383–437  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

381}
382
383func TestDeduplicate_JSONFormat(t *testing.T) {
384 tmpDir := t.TempDir()
385 resetDedupFlags()
386 dedupFormat = "json"
387 dedupNoInteractive = true
388
389 createTaskFile(t, tmpDir, "001-task-a.md", `---
390id: "001"
391title: "Task A"
392status: pending
393priority: medium
394dependencies: []
395tags: []
396created: 2026-01-01
397---
398
399# Task A
400`)
401
402 createTaskFile(t, tmpDir, "001-task-b.md", `---
403id: "001"
404title: "Task B"
405status: pending
406priority: medium
407dependencies: []
408tags: []
409created: 2026-01-15
410---
411
412# Task B
413`)
414
415 output, err := captureDedup(t, tmpDir)
416 if err != nil {
417 t.Fatalf("unexpected error: %v", err)
418 }
419
420 var result deduplicateResult
421 if err := json.Unmarshal([]byte(output), &result); err != nil {
422 t.Fatalf("expected valid JSON output, got error: %v\noutput: %s", err, output)
423 }
424
425 if result.Duplicates != 1 {
426 t.Errorf("expected 1 duplicate, got %d", result.Duplicates)
427 }
428 if len(result.Reassignments) != 1 {
429 t.Fatalf("expected 1 reassignment, got %d", len(result.Reassignments))
430 }
431 if result.Reassignments[0].OldID != "001" {
432 t.Errorf("expected old ID '001', got %q", result.Reassignments[0].OldID)
433 }
434 if result.Reassignments[0].NewID == "001" {
435 t.Error("expected new ID to be different from '001'")
436 }
437}
438
439func TestDeduplicate_NoDuplicates_JSON(t *testing.T) {
440 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 4

resetDedupFlagsFunction · 0.85
captureDedupFunction · 0.85
ErrorMethod · 0.80
createTaskFileFunction · 0.70

Tested by

no test coverage detected