Files
fn_registry/functions/infra/scan_flows_dir_test.go
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

67 lines
1.4 KiB
Go

package infra
import (
"path/filepath"
"testing"
)
func TestScanFlowsDir(t *testing.T) {
root := registryRoot()
flowsDir := filepath.Join(root, "dev", "flows")
t.Run("scan devuelve al menos 5 flows", func(t *testing.T) {
flows, err := ScanFlowsDir(flowsDir)
if err != nil {
t.Fatalf("ScanFlowsDir: %v", err)
}
if len(flows) < 5 {
t.Errorf("expected >= 5 flows, got %d", len(flows))
}
})
t.Run("flow 0001 esta presente", func(t *testing.T) {
flows, err := ScanFlowsDir(flowsDir)
if err != nil {
t.Fatalf("ScanFlowsDir: %v", err)
}
found := false
for _, f := range flows {
if f.ID == "0001" {
found = true
break
}
}
if !found {
t.Error("flow 0001 not found in scan results")
}
})
t.Run("flows tienen FilePath y MtimeNs", func(t *testing.T) {
flows, err := ScanFlowsDir(flowsDir)
if err != nil {
t.Fatalf("ScanFlowsDir: %v", err)
}
for _, f := range flows {
if f.FilePath == "" {
t.Errorf("flow %q has empty FilePath", f.ID)
}
if f.MtimeNs == 0 {
t.Errorf("flow %q has zero MtimeNs", f.ID)
}
}
})
t.Run("flows ordenados por ID asc", func(t *testing.T) {
flows, err := ScanFlowsDir(flowsDir)
if err != nil {
t.Fatalf("ScanFlowsDir: %v", err)
}
for i := 1; i < len(flows); i++ {
if flows[i].ID < flows[i-1].ID {
t.Errorf("not sorted at index %d: %q < %q", i, flows[i].ID, flows[i-1].ID)
break
}
}
})
}