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

Function TestBuildFileDetail

handoff/handoff_test.go:261–302  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

259}
260
261func TestBuildFileDetail(t *testing.T) {
262 root := t.TempDir()
263 runCmd(t, root, "git", "init")
264 if err := os.WriteFile(filepath.Join(root, "a.go"), []byte("package main\n"), 0644); err != nil {
265 t.Fatal(err)
266 }
267 runCmd(t, root, "git", "add", ".")
268 runCmd(t, root, "git", "-c", "user.name=Test", "-c", "user.email=test@example.com", "commit", "-m", "init")
269 if err := os.WriteFile(filepath.Join(root, "a.go"), []byte("package main\n\n// changed\n"), 0644); err != nil {
270 t.Fatal(err)
271 }
272
273 state := &watch.State{
274 Importers: map[string][]string{
275 "a.go": {"x.go", "y.go", "z.go"},
276 },
277 Imports: map[string][]string{
278 "a.go": {"dep.go"},
279 },
280 RecentEvents: []watch.Event{
281 {Time: time.Now(), Op: "WRITE", Path: "a.go", Delta: 2, IsHub: true},
282 },
283 }
284
285 artifact, err := Build(root, BuildOptions{BaseRef: "HEAD", State: state})
286 if err != nil {
287 t.Fatalf("build failed: %v", err)
288 }
289 detail, err := BuildFileDetail(root, artifact, "a.go", state)
290 if err != nil {
291 t.Fatalf("BuildFileDetail failed: %v", err)
292 }
293 if detail.Path != "a.go" {
294 t.Fatalf("expected path a.go, got %s", detail.Path)
295 }
296 if !detail.IsHub {
297 t.Fatalf("expected a.go to be marked as hub detail")
298 }
299 if len(detail.Importers) != 3 {
300 t.Fatalf("expected 3 importers, got %d", len(detail.Importers))
301 }
302}
303
304func TestMetricsLogCapped(t *testing.T) {
305 root := t.TempDir()

Callers

nothing calls this directly

Calls 3

runCmdFunction · 0.85
BuildFunction · 0.85
BuildFileDetailFunction · 0.85

Tested by

no test coverage detected