Files
fn_registry/functions/infra/scan_issues_dir_test.go
T
Egutierrez c468b24d2b feat(0130): kanban_cpp v2 — backend Go + 5 registry parser fns + epic/sub-issues
Registry (issue 0130a):
- 5 fns infra: parse_issue_md, write_issue_md, scan_issues_dir,
  scan_flows_dir, watch_dir_fsnotify
- 3 tipos: Issue, Flow, FsEvent
- Tests round-trip + scan reales + watcher fsnotify (all PASS)
- Capability group 'kanban' nuevo (docs/capabilities/kanban.md)

Apps:
- apps/kanban_cpp/ (sub-repo) — frontend ImGui: board drag-drop,
  flows, filters, detail con CSV editors
- apps/kanban_cpp/backend/ — Go service port 8487: REST + SSE +
  fsnotify watcher, parser bidireccional MD<->SQLite cache

Issues:
- dev/issues/0130-kanban-cpp-v2.md (epic)
- 0130a parser, 0130b backend, 0130c frontend

CMakeLists.txt: add_subdirectory apps/kanban_cpp (registrado por
init_cpp_app scaffolder).

End-to-end verde: backend devuelve 189 issues + 9 flows; PATCH a
/api/issues/{id} reescribe .md (solo frontmatter, body intacto);
frontend --self-test exit 0; tests Go infra 5/5 PASS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 22:20:15 +02:00

75 lines
1.6 KiB
Go

package infra
import (
"path/filepath"
"testing"
)
func TestScanIssuesDir(t *testing.T) {
root := registryRoot()
issuesDir := filepath.Join(root, "dev", "issues")
t.Run("scan devuelve al menos 90 issues", func(t *testing.T) {
issues, err := ScanIssuesDir(issuesDir)
if err != nil {
t.Fatalf("ScanIssuesDir: %v", err)
}
if len(issues) < 90 {
t.Errorf("expected >= 90 issues, got %d", len(issues))
}
})
t.Run("issue 0130 esta presente", func(t *testing.T) {
issues, err := ScanIssuesDir(issuesDir)
if err != nil {
t.Fatalf("ScanIssuesDir: %v", err)
}
found := false
for _, iss := range issues {
if iss.ID == "0130" {
found = true
break
}
}
if !found {
t.Error("issue 0130 not found in scan results")
}
})
t.Run("issues ordenados por ID asc", func(t *testing.T) {
issues, err := ScanIssuesDir(issuesDir)
if err != nil {
t.Fatalf("ScanIssuesDir: %v", err)
}
for i := 1; i < len(issues); i++ {
if issues[i].ID < issues[i-1].ID {
t.Errorf("not sorted at index %d: %q < %q", i, issues[i].ID, issues[i-1].ID)
break
}
}
})
t.Run("completed issues tienen Completed=true", func(t *testing.T) {
issues, err := ScanIssuesDir(issuesDir)
if err != nil {
t.Fatalf("ScanIssuesDir: %v", err)
}
completedCount := 0
for _, iss := range issues {
if iss.Completed {
completedCount++
}
}
if completedCount == 0 {
t.Error("expected at least some completed issues")
}
})
t.Run("directorio inexistente retorna error", func(t *testing.T) {
_, err := ScanIssuesDir("/nonexistent/dev/issues")
if err == nil {
t.Error("expected error for nonexistent directory")
}
})
}