(t *testing.T)
| 496 | } |
| 497 | |
| 498 | func TestDepsBuildFileIndex(t *testing.T) { |
| 499 | handlerPath := filepath.FromSlash("pkg/service/handler.go") |
| 500 | files := []FileInfo{ |
| 501 | {Path: "main.go"}, |
| 502 | {Path: handlerPath}, |
| 503 | {Path: filepath.FromSlash("src/modules/auth/index.ts")}, |
| 504 | } |
| 505 | |
| 506 | idx := buildFileIndex(files, "example.com/project") |
| 507 | |
| 508 | handlerDir := filepath.Dir(handlerPath) |
| 509 | if got := idx.byDir[handlerDir]; len(got) != 1 || got[0] != handlerPath { |
| 510 | t.Fatalf("expected %q in byDir, got %v", handlerPath, got) |
| 511 | } |
| 512 | handlerNoExt := strings.TrimSuffix(handlerPath, filepath.Ext(handlerPath)) |
| 513 | if got := idx.byExact[handlerNoExt]; len(got) != 1 || got[0] != handlerPath { |
| 514 | t.Fatalf("expected no-ext exact match for handler.go, got %v", got) |
| 515 | } |
| 516 | handlerSuffix := filepath.Join("service", "handler.go") |
| 517 | if got := idx.bySuffix[handlerSuffix]; len(got) != 1 || got[0] != handlerPath { |
| 518 | t.Fatalf("expected suffix match for service/handler.go, got %v", got) |
| 519 | } |
| 520 | if got := idx.goPkgs["example.com/project/pkg/service"]; len(got) != 1 || got[0] != handlerPath { |
| 521 | t.Fatalf("expected go package index for pkg/service, got %v", got) |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | func TestDepsNormalizeImport(t *testing.T) { |
| 526 | tests := []struct { |
nothing calls this directly
no test coverage detected