(t *testing.T)
| 531 | } |
| 532 | |
| 533 | func TestRunValidate_WithArchive(t *testing.T) { |
| 534 | tmpDir := t.TempDir() |
| 535 | |
| 536 | // Active task that depends on an archived task |
| 537 | activeTask := `--- |
| 538 | id: "010" |
| 539 | title: "Active Task" |
| 540 | status: pending |
| 541 | dependencies: ["050"] |
| 542 | --- |
| 543 | |
| 544 | Depends on archived task. |
| 545 | ` |
| 546 | if err := os.WriteFile(filepath.Join(tmpDir, "010-active.md"), []byte(activeTask), 0644); err != nil { |
| 547 | t.Fatalf("failed to create test file: %v", err) |
| 548 | } |
| 549 | |
| 550 | // Archived task in archive directory |
| 551 | archiveDir := filepath.Join(tmpDir, "archive") |
| 552 | if err := os.MkdirAll(archiveDir, 0755); err != nil { |
| 553 | t.Fatalf("failed to create archive dir: %v", err) |
| 554 | } |
| 555 | archivedTask := `--- |
| 556 | id: "050" |
| 557 | title: "Archived Task" |
| 558 | status: completed |
| 559 | --- |
| 560 | |
| 561 | Done. |
| 562 | ` |
| 563 | if err := os.WriteFile(filepath.Join(archiveDir, "050-archived.md"), []byte(archivedTask), 0644); err != nil { |
| 564 | t.Fatalf("failed to create archived file: %v", err) |
| 565 | } |
| 566 | |
| 567 | resetValidateFlags() |
| 568 | validateFormat = "json" |
| 569 | |
| 570 | output, err := captureValidateOutput(t, []string{tmpDir}) |
| 571 | if err != nil { |
| 572 | t.Fatalf("runValidate failed: %v", err) |
| 573 | } |
| 574 | |
| 575 | var parsed validator.ValidationResult |
| 576 | if err := json.Unmarshal([]byte(output), &parsed); err != nil { |
| 577 | t.Fatalf("failed to parse JSON: %v\noutput: %s", err, output) |
| 578 | } |
| 579 | |
| 580 | // Should NOT have a missing dependency error since "050" is in archive |
| 581 | for _, issue := range parsed.Issues { |
| 582 | if strings.Contains(issue.Message, "non-existent task: '050'") { |
| 583 | t.Error("archived task ID should not trigger missing dependency error") |
| 584 | } |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | func TestCollectArchivedIDs(t *testing.T) { |
| 589 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected