(t *testing.T)
| 121 | } |
| 122 | |
| 123 | func 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 | |
| 160 | func TestHandleGetHandoffValidationAndLatest(t *testing.T) { |
| 161 | root := t.TempDir() |
nothing calls this directly
no test coverage detected