MCPcopy Create free account
hub / github.com/zalando/skipper / TestLoopbackWithResponse

Function TestLoopbackWithResponse

proxy/loopback_test.go:408–448  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

406}
407
408func 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 := `
417INTERNAL_REDIRECT: Path("/internal-redirect/") -> loopbackIfStatus(418, "/tea-pot")-> status(418) -> <shunt>;
418NO_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
450func getUrl(path string) *url.URL {
451 return &url.URL{

Callers

nothing calls this directly

Calls 5

MakeRegistryFunction · 0.92
NewLoopbackIfStatusFunction · 0.92
getUrlFunction · 0.85
testLoopbackFunction · 0.85
RegisterMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…