(t *testing.T)
| 181 | } |
| 182 | |
| 183 | func TestFuzzyResolve(t *testing.T) { |
| 184 | files := []FileInfo{ |
| 185 | {Path: filepath.Join("pkg", "util", "helpers.go")}, |
| 186 | {Path: filepath.Join("pkg", "models", "user.go")}, |
| 187 | {Path: filepath.Join("src", "modules", "auth", "login.ts")}, |
| 188 | {Path: filepath.Join("src", "shared", "config.py")}, |
| 189 | {Path: filepath.Join("src", "services", "__init__.py")}, |
| 190 | } |
| 191 | idx := buildFileIndex(files, "example.com/project") |
| 192 | |
| 193 | pathAliases := map[string][]string{ |
| 194 | "@modules/*": {"src/modules/*"}, |
| 195 | } |
| 196 | |
| 197 | tests := []struct { |
| 198 | name string |
| 199 | imp string |
| 200 | fromFile string |
| 201 | aliases map[string][]string |
| 202 | baseURL string |
| 203 | expected []string |
| 204 | }{ |
| 205 | { |
| 206 | name: "go package strategy", |
| 207 | imp: "example.com/project/pkg/util", |
| 208 | fromFile: filepath.Join("pkg", "models", "user.go"), |
| 209 | aliases: nil, |
| 210 | baseURL: "", |
| 211 | expected: []string{filepath.Join("pkg", "util", "helpers.go")}, |
| 212 | }, |
| 213 | { |
| 214 | name: "relative strategy", |
| 215 | imp: "../util/helpers", |
| 216 | fromFile: filepath.Join("pkg", "models", "user.go"), |
| 217 | aliases: nil, |
| 218 | baseURL: "", |
| 219 | expected: []string{filepath.Join("pkg", "util", "helpers.go")}, |
| 220 | }, |
| 221 | { |
| 222 | name: "path alias strategy", |
| 223 | imp: "@modules/auth/login", |
| 224 | fromFile: filepath.Join("src", "shared", "config.py"), |
| 225 | aliases: pathAliases, |
| 226 | baseURL: ".", |
| 227 | expected: []string{filepath.Join("src", "modules", "auth", "login.ts")}, |
| 228 | }, |
| 229 | { |
| 230 | name: "normalized dotted exact strategy", |
| 231 | imp: "src.shared.config", |
| 232 | fromFile: filepath.Join("src", "modules", "auth", "login.ts"), |
| 233 | aliases: nil, |
| 234 | baseURL: "", |
| 235 | expected: []string{filepath.Join("src", "shared", "config.py")}, |
| 236 | }, |
| 237 | { |
| 238 | name: "suffix strategy with python init", |
| 239 | imp: "services", |
| 240 | fromFile: filepath.Join("src", "shared", "config.py"), |
nothing calls this directly
no test coverage detected