(t *testing.T)
| 381 | } |
| 382 | |
| 383 | func 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", `--- |
| 390 | id: "001" |
| 391 | title: "Task A" |
| 392 | status: pending |
| 393 | priority: medium |
| 394 | dependencies: [] |
| 395 | tags: [] |
| 396 | created: 2026-01-01 |
| 397 | --- |
| 398 | |
| 399 | # Task A |
| 400 | `) |
| 401 | |
| 402 | createTaskFile(t, tmpDir, "001-task-b.md", `--- |
| 403 | id: "001" |
| 404 | title: "Task B" |
| 405 | status: pending |
| 406 | priority: medium |
| 407 | dependencies: [] |
| 408 | tags: [] |
| 409 | created: 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 | |
| 439 | func TestDeduplicate_NoDuplicates_JSON(t *testing.T) { |
| 440 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected