(t *testing.T)
| 187 | } |
| 188 | |
| 189 | func TestResolveResourcePath(t *testing.T) { |
| 190 | t.Parallel() |
| 191 | |
| 192 | tests := []struct { |
| 193 | name string |
| 194 | cfg *Config |
| 195 | setupRequest func() *http.Request |
| 196 | expectedPath string |
| 197 | }{ |
| 198 | { |
| 199 | name: "no base path uses request path", |
| 200 | cfg: &Config{}, |
| 201 | setupRequest: func() *http.Request { |
| 202 | return httptest.NewRequest(http.MethodGet, "/x/repos", nil) |
| 203 | }, |
| 204 | expectedPath: "/x/repos", |
| 205 | }, |
| 206 | { |
| 207 | name: "base path restored for root", |
| 208 | cfg: &Config{ |
| 209 | ResourcePath: "/mcp", |
| 210 | }, |
| 211 | setupRequest: func() *http.Request { |
| 212 | return httptest.NewRequest(http.MethodGet, "/", nil) |
| 213 | }, |
| 214 | expectedPath: "/mcp", |
| 215 | }, |
| 216 | { |
| 217 | name: "base path restored for nested", |
| 218 | cfg: &Config{ |
| 219 | ResourcePath: "/mcp", |
| 220 | }, |
| 221 | setupRequest: func() *http.Request { |
| 222 | return httptest.NewRequest(http.MethodGet, "/readonly", nil) |
| 223 | }, |
| 224 | expectedPath: "/mcp/readonly", |
| 225 | }, |
| 226 | { |
| 227 | name: "base path preserved when already present", |
| 228 | cfg: &Config{ |
| 229 | ResourcePath: "/mcp", |
| 230 | }, |
| 231 | setupRequest: func() *http.Request { |
| 232 | return httptest.NewRequest(http.MethodGet, "/mcp/readonly/", nil) |
| 233 | }, |
| 234 | expectedPath: "/mcp/readonly/", |
| 235 | }, |
| 236 | { |
| 237 | name: "custom base path restored", |
| 238 | cfg: &Config{ |
| 239 | ResourcePath: "/api", |
| 240 | }, |
| 241 | setupRequest: func() *http.Request { |
| 242 | return httptest.NewRequest(http.MethodGet, "/x/repos", nil) |
| 243 | }, |
| 244 | expectedPath: "/api/x/repos", |
| 245 | }, |
| 246 | } |
nothing calls this directly
no test coverage detected