--- findFileInRepo ---
(t *testing.T)
| 145 | // --- findFileInRepo --- |
| 146 | |
| 147 | func TestFindFileInRepo(t *testing.T) { |
| 148 | root := t.TempDir() |
| 149 | writeTestFile(t, filepath.Join(root, "pkg", "util.go"), "package util\n") |
| 150 | writeTestFile(t, filepath.Join(root, "src", "app.py"), "print('hi')\n") |
| 151 | writeTestFile(t, filepath.Join(root, "a", "b", "c", "deep.go"), "package c\n") |
| 152 | writeTestFile(t, filepath.Join(root, "vendor", "dep", "hidden.go"), "package dep\n") |
| 153 | |
| 154 | t.Run("direct relative match", func(t *testing.T) { |
| 155 | got := findFileInRepo(root, filepath.Join("pkg", "util.go"), nil) |
| 156 | if got != filepath.Join(root, "pkg", "util.go") { |
| 157 | t.Errorf("got %q", got) |
| 158 | } |
| 159 | }) |
| 160 | |
| 161 | t.Run("match within relevant paths", func(t *testing.T) { |
| 162 | got := findFileInRepo(root, "app.py", []string{"src"}) |
| 163 | if got != filepath.Join(root, "src", "app.py") { |
| 164 | t.Errorf("got %q", got) |
| 165 | } |
| 166 | }) |
| 167 | |
| 168 | t.Run("basename walk fallback", func(t *testing.T) { |
| 169 | got := findFileInRepo(root, filepath.Join("wrong", "prefix", "deep.go"), nil) |
| 170 | if got != filepath.Join(root, "a", "b", "c", "deep.go") { |
| 171 | t.Errorf("got %q", got) |
| 172 | } |
| 173 | }) |
| 174 | |
| 175 | t.Run("vendor is skipped by the walk", func(t *testing.T) { |
| 176 | if got := findFileInRepo(root, "hidden.go", nil); got != "" { |
| 177 | t.Errorf("expected vendor/ to be skipped, got %q", got) |
| 178 | } |
| 179 | }) |
| 180 | |
| 181 | t.Run("not found", func(t *testing.T) { |
| 182 | if got := findFileInRepo(root, "nope.go", nil); got != "" { |
| 183 | t.Errorf("expected empty result, got %q", got) |
| 184 | } |
| 185 | }) |
| 186 | } |
| 187 | |
| 188 | // --- readConfigFiles --- |
| 189 |
nothing calls this directly
no test coverage detected