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

Function TestHandleGetStructureUsesStateHubs

mcp/main_test.go:123–158  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

121}
122
123func TestHandleGetStructureUsesStateHubs(t *testing.T) {
124 root := t.TempDir()
125 if err := os.MkdirAll(filepath.Join(root, ".codemap"), 0o755); err != nil {
126 t.Fatal(err)
127 }
128 if err := os.MkdirAll(filepath.Join(root, "pkg"), 0o755); err != nil {
129 t.Fatal(err)
130 }
131 if err := os.WriteFile(filepath.Join(root, "pkg", "main.go"), []byte("package main\n"), 0o644); err != nil {
132 t.Fatal(err)
133 }
134 state := watch.State{
135 UpdatedAt: time.Now(),
136 Hubs: []string{"pkg/main.go"},
137 Importers: map[string][]string{"pkg/main.go": {"a.go", "b.go", "c.go"}},
138 }
139 data, err := json.Marshal(state)
140 if err != nil {
141 t.Fatal(err)
142 }
143 if err := os.WriteFile(filepath.Join(root, ".codemap", "state.json"), data, 0o644); err != nil {
144 t.Fatal(err)
145 }
146
147 res, _, err := handleGetStructure(context.Background(), nil, PathInput{Path: root})
148 if err != nil {
149 t.Fatalf("handleGetStructure error: %v", err)
150 }
151 out := resultText(t, res)
152 checks := []string{"HUB FILES", "pkg/main.go", "3 importers"}
153 for _, check := range checks {
154 if !strings.Contains(out, check) {
155 t.Fatalf("expected output to contain %q, got:\n%s", check, out)
156 }
157 }
158}
159
160func TestHandleGetHandoffValidationAndLatest(t *testing.T) {
161 root := t.TempDir()

Callers

nothing calls this directly

Calls 2

handleGetStructureFunction · 0.85
resultTextFunction · 0.85

Tested by

no test coverage detected