(t *testing.T)
| 54 | } |
| 55 | |
| 56 | func TestBuildFileIndex(t *testing.T) { |
| 57 | files := []FileInfo{ |
| 58 | {Path: "main.go"}, |
| 59 | {Path: filepath.Join("pkg", "util", "helpers.go")}, |
| 60 | {Path: filepath.Join("src", "app", "core", "config.py")}, |
| 61 | } |
| 62 | |
| 63 | idx := buildFileIndex(files, "example.com/project") |
| 64 | |
| 65 | tests := []struct { |
| 66 | name string |
| 67 | got []string |
| 68 | want []string |
| 69 | }{ |
| 70 | { |
| 71 | name: "exact lookup without extension", |
| 72 | got: idx.byExact[filepath.Join("pkg", "util", "helpers")], |
| 73 | want: []string{filepath.Join("pkg", "util", "helpers.go")}, |
| 74 | }, |
| 75 | { |
| 76 | name: "suffix lookup for nested path", |
| 77 | got: idx.bySuffix[filepath.Join("app", "core", "config.py")], |
| 78 | want: []string{filepath.Join("src", "app", "core", "config.py")}, |
| 79 | }, |
| 80 | { |
| 81 | name: "directory lookup", |
| 82 | got: idx.byDir[filepath.Join("pkg", "util")], |
| 83 | want: []string{filepath.Join("pkg", "util", "helpers.go")}, |
| 84 | }, |
| 85 | { |
| 86 | name: "go package lookup", |
| 87 | got: idx.goPkgs["example.com/project/pkg/util"], |
| 88 | want: []string{filepath.Join("pkg", "util", "helpers.go")}, |
| 89 | }, |
| 90 | } |
| 91 | |
| 92 | for _, tt := range tests { |
| 93 | t.Run(tt.name, func(t *testing.T) { |
| 94 | if !reflect.DeepEqual(tt.got, tt.want) { |
| 95 | t.Errorf("%s: got %v, want %v", tt.name, tt.got, tt.want) |
| 96 | } |
| 97 | }) |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | func TestResolveRelative(t *testing.T) { |
| 102 | files := []FileInfo{ |
nothing calls this directly
no test coverage detected