MCPcopy Create free account
hub / github.com/JordanCoin/codemap / TestLoad_ValidConfig

Function TestLoad_ValidConfig

config/config_test.go:19–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17}
18
19func TestLoad_ValidConfig(t *testing.T) {
20 dir := t.TempDir()
21 codemapDir := filepath.Join(dir, ".codemap")
22 if err := os.MkdirAll(codemapDir, 0755); err != nil {
23 t.Fatal(err)
24 }
25
26 data := `{
27 "only": ["rs", "sh", "sql"],
28 "exclude": ["docs/reference", "vendor"],
29 "depth": 3,
30 "mode": "structured",
31 "budgets": {
32 "session_start_bytes": 28000,
33 "diff_bytes": 11000,
34 "max_hubs": 6
35 },
36 "routing": {
37 "retrieval": {
38 "strategy": "keyword",
39 "top_k": 4
40 },
41 "subsystems": [
42 {
43 "id": "watching",
44 "keywords": ["hook", "daemon"],
45 "docs": ["docs/HOOKS.md"],
46 "agents": ["codemap-hook-triage"]
47 }
48 ]
49 },
50 "drift": {
51 "enabled": true,
52 "recent_commits": 9,
53 "require_docs_for": ["watching"]
54 }
55 }`
56 if err := os.WriteFile(filepath.Join(codemapDir, "config.json"), []byte(data), 0644); err != nil {
57 t.Fatal(err)
58 }
59
60 cfg := Load(dir)
61 if len(cfg.Only) != 3 || cfg.Only[0] != "rs" || cfg.Only[1] != "sh" || cfg.Only[2] != "sql" {
62 t.Errorf("unexpected Only: %v", cfg.Only)
63 }
64 if len(cfg.Exclude) != 2 || cfg.Exclude[0] != "docs/reference" || cfg.Exclude[1] != "vendor" {
65 t.Errorf("unexpected Exclude: %v", cfg.Exclude)
66 }
67 if cfg.Depth != 3 {
68 t.Errorf("unexpected Depth: %d", cfg.Depth)
69 }
70 if cfg.Mode != "structured" {
71 t.Errorf("unexpected Mode: %q", cfg.Mode)
72 }
73 if cfg.Budgets.SessionStartBytes != 28000 {
74 t.Errorf("unexpected SessionStartBytes: %d", cfg.Budgets.SessionStartBytes)
75 }
76 if cfg.Budgets.DiffBytes != 11000 {

Callers

nothing calls this directly

Calls 2

LoadFunction · 0.85
RoutingTopKOrDefaultMethod · 0.80

Tested by

no test coverage detected