(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestPredicateList(t *testing.T) { |
| 16 | type check struct { |
| 17 | request *http.Request |
| 18 | expectedID string |
| 19 | allowedIDs []string |
| 20 | expectedParams map[string]string |
| 21 | } |
| 22 | |
| 23 | for _, test := range []struct { |
| 24 | title string |
| 25 | options MatchingOptions |
| 26 | routes []*eskip.Route |
| 27 | checks []check |
| 28 | }{{ |
| 29 | |
| 30 | title: "only legacy predicate", |
| 31 | routes: []*eskip.Route{{ |
| 32 | Id: "test", |
| 33 | Headers: map[string]string{ |
| 34 | "X-Test": "foo", |
| 35 | }, |
| 36 | BackendType: eskip.ShuntBackend, |
| 37 | }, { |
| 38 | Id: "catchAll", |
| 39 | BackendType: eskip.ShuntBackend, |
| 40 | }}, |
| 41 | checks: []check{{ |
| 42 | request: &http.Request{ |
| 43 | URL: &url.URL{Path: "/"}, |
| 44 | Header: http.Header{ |
| 45 | "X-Test": []string{"foo"}, |
| 46 | }, |
| 47 | }, |
| 48 | expectedID: "test", |
| 49 | }, { |
| 50 | request: &http.Request{ |
| 51 | URL: &url.URL{Path: "/"}, |
| 52 | }, |
| 53 | expectedID: "catchAll", |
| 54 | }}, |
| 55 | }, { |
| 56 | |
| 57 | title: "only legacy predicate, path", |
| 58 | routes: []*eskip.Route{{ |
| 59 | Id: "test", |
| 60 | Path: "/foo", |
| 61 | BackendType: eskip.ShuntBackend, |
| 62 | }, { |
| 63 | Id: "catchAll", |
| 64 | BackendType: eskip.ShuntBackend, |
| 65 | }}, |
| 66 | checks: []check{{ |
| 67 | request: &http.Request{ |
| 68 | URL: &url.URL{Path: "/foo"}, |
| 69 | }, |
| 70 | expectedID: "test", |
| 71 | }, { |
| 72 | request: &http.Request{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…