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

Function TestRunValidate_WithArchive

apps/cli/internal/cli/validate_test.go:533–586  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

531}
532
533func TestRunValidate_WithArchive(t *testing.T) {
534 tmpDir := t.TempDir()
535
536 // Active task that depends on an archived task
537 activeTask := `---
538id: "010"
539title: "Active Task"
540status: pending
541dependencies: ["050"]
542---
543
544Depends 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 := `---
556id: "050"
557title: "Archived Task"
558status: completed
559---
560
561Done.
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
588func TestCollectArchivedIDs(t *testing.T) {
589 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 3

resetValidateFlagsFunction · 0.85
captureValidateOutputFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected