(t *testing.T)
| 99 | } |
| 100 | |
| 101 | func TestResolveRelative(t *testing.T) { |
| 102 | files := []FileInfo{ |
| 103 | {Path: filepath.Join("pkg", "util", "helpers.go")}, |
| 104 | {Path: filepath.Join("pkg", "models", "user.go")}, |
| 105 | } |
| 106 | idx := buildFileIndex(files, "") |
| 107 | |
| 108 | tests := []struct { |
| 109 | name string |
| 110 | imp string |
| 111 | fromDir string |
| 112 | expected []string |
| 113 | }{ |
| 114 | { |
| 115 | name: "same directory", |
| 116 | imp: "./helpers", |
| 117 | fromDir: filepath.Join("pkg", "util"), |
| 118 | expected: []string{filepath.Join("pkg", "util", "helpers.go")}, |
| 119 | }, |
| 120 | { |
| 121 | name: "parent directory", |
| 122 | imp: "../models/user", |
| 123 | fromDir: filepath.Join("pkg", "util"), |
| 124 | expected: []string{filepath.Join("pkg", "models", "user.go")}, |
| 125 | }, |
| 126 | { |
| 127 | name: "missing file", |
| 128 | imp: "./missing", |
| 129 | fromDir: filepath.Join("pkg", "util"), |
| 130 | expected: nil, |
| 131 | }, |
| 132 | } |
| 133 | |
| 134 | for _, tt := range tests { |
| 135 | t.Run(tt.name, func(t *testing.T) { |
| 136 | got := resolveRelative(tt.imp, tt.fromDir, idx) |
| 137 | if !reflect.DeepEqual(got, tt.expected) { |
| 138 | t.Errorf("resolveRelative(%q, %q) = %v, want %v", tt.imp, tt.fromDir, got, tt.expected) |
| 139 | } |
| 140 | }) |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | func TestTrySuffixMatch(t *testing.T) { |
| 145 | files := []FileInfo{ |
nothing calls this directly
no test coverage detected