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

Function TestCollectArchivedIDs

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

Source from the content-addressed store, hash-verified

586}
587
588func TestCollectArchivedIDs(t *testing.T) {
589 tmpDir := t.TempDir()
590
591 // Create archive directory with task files
592 archiveDir := filepath.Join(tmpDir, "archive")
593 if err := os.MkdirAll(archiveDir, 0755); err != nil {
594 t.Fatalf("failed to create archive dir: %v", err)
595 }
596
597 tasks := map[string]string{
598 "050-done.md": `---
599id: "050"
600title: "Archived 050"
601status: completed
602---
603Done.
604`,
605 "051-done.md": `---
606id: "051"
607title: "Archived 051"
608status: completed
609---
610Done.
611`,
612 }
613 for name, content := range tasks {
614 if err := os.WriteFile(filepath.Join(archiveDir, name), []byte(content), 0644); err != nil {
615 t.Fatalf("failed to create test file: %v", err)
616 }
617 }
618
619 s := scanner.NewScanner(tmpDir, false, nil)
620 ids := collectArchivedIDs(s)
621
622 if len(ids) != 2 {
623 t.Fatalf("expected 2 archived IDs, got %d", len(ids))
624 }
625 if !ids["050"] {
626 t.Error("expected archived ID '050'")
627 }
628 if !ids["051"] {
629 t.Error("expected archived ID '051'")
630 }
631}
632
633func TestCollectArchivedIDs_NoArchive(t *testing.T) {
634 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 2

collectArchivedIDsFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected