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

Function TestRoutingHandlerInvalidRoutesText

routing/routing_test.go:1119–1159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1117}
1118
1119func TestRoutingHandlerInvalidRoutesText(t *testing.T) {
1120 dc, _ := testdataclient.NewDoc(`
1121 route1: CustomPredicate("custom1") -> "https://route1.example.org";
1122 route2: FooBar("custom2") -> "https://route2.example.org";
1123 catchAll: * -> "https://route.example.org"`)
1124 defer dc.Close()
1125
1126 cps := []routing.PredicateSpec{&predicate{}, &predicate{}}
1127 tr, _ := newTestRoutingWithPredicates(cps, dc)
1128 defer tr.close()
1129
1130 mux := http.NewServeMux()
1131 mux.Handle("/", tr.routing)
1132 server := httptest.NewServer(mux)
1133 defer server.Close()
1134
1135 req, _ := http.NewRequest("GET", server.URL+"?invalid=true", nil)
1136 resp, err := http.DefaultClient.Do(req)
1137 if err != nil {
1138 t.Fatalf("failed to request invalid routes: %v", err)
1139 }
1140 defer resp.Body.Close()
1141
1142 if got, want := resp.Header.Get("content-type"), "text/plain"; got != want {
1143 t.Errorf("content type = %v, want %v", got, want)
1144 }
1145
1146 b, _ := io.ReadAll(resp.Body)
1147 routes, err := eskip.Parse(string(b))
1148 if err != nil {
1149 t.Fatalf("failed to parse eskip response: %v", err)
1150 }
1151
1152 if got, want := len(routes), 1; got != want {
1153 t.Fatalf("invalid routes count = %v, want %v", got, want)
1154 }
1155
1156 if routes[0].Id != "route2" {
1157 t.Errorf("invalid route id = %v, want route2", routes[0].Id)
1158 }
1159}
1160
1161func TestRoutingHandlerInvalidRoutesHEAD(t *testing.T) {
1162 dc, _ := testdataclient.NewDoc(`

Callers

nothing calls this directly

Calls 8

NewDocFunction · 0.92
ParseFunction · 0.92
CloseMethod · 0.65
DoMethod · 0.65
GetMethod · 0.65
ErrorfMethod · 0.65
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…