(t *testing.T)
| 406 | } |
| 407 | |
| 408 | func TestLoopbackWithResponse(t *testing.T) { |
| 409 | // create registry |
| 410 | registry := builtin.MakeRegistry() |
| 411 | |
| 412 | // create and register the filter specification |
| 413 | spec := builtin.NewLoopbackIfStatus() |
| 414 | registry.Register(spec) |
| 415 | |
| 416 | routes := ` |
| 417 | INTERNAL_REDIRECT: Path("/internal-redirect/") -> loopbackIfStatus(418, "/tea-pot")-> status(418) -> <shunt>; |
| 418 | NO_RESULTS: Path("/tea-pot") -> status(200) -> inlineContent("I'm a teapot, not a search engine", "text/plain'") -> <shunt>; |
| 419 | ` |
| 420 | |
| 421 | for _, ti := range []struct { |
| 422 | msg string |
| 423 | input *url.URL |
| 424 | expectedStatus int |
| 425 | }{ |
| 426 | { |
| 427 | msg: "request to internal redirect", |
| 428 | input: getUrl("/internal-redirect/"), |
| 429 | expectedStatus: 200, |
| 430 | }, |
| 431 | { |
| 432 | msg: "request to tea-pot", |
| 433 | input: getUrl("/tea-pot"), |
| 434 | expectedStatus: 200, |
| 435 | }, |
| 436 | { |
| 437 | msg: "request to non-existing path", |
| 438 | input: getUrl("/non-existing"), |
| 439 | expectedStatus: 404, |
| 440 | }, |
| 441 | } { |
| 442 | t.Run(ti.msg, func(t *testing.T) { |
| 443 | |
| 444 | testLoopback(t, routes, Params{}, ti.input, ti.expectedStatus, http.Header{}) |
| 445 | |
| 446 | }) |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | func getUrl(path string) *url.URL { |
| 451 | return &url.URL{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…