(t *testing.T)
| 13 | func takePt(n int) *int { return &n } |
| 14 | |
| 15 | func TestDebug(t *testing.T) { |
| 16 | for _, ti := range []struct { |
| 17 | msg string |
| 18 | in debugInfo |
| 19 | expect debugDocument |
| 20 | }{{ |
| 21 | "empty debug info", |
| 22 | debugInfo{}, |
| 23 | debugDocument{}, |
| 24 | }, { |
| 25 | "full doc", |
| 26 | debugInfo{ |
| 27 | route: &eskip.Route{ |
| 28 | Id: "testRoute", |
| 29 | Path: "/hello", |
| 30 | Backend: "https://www.example.org", |
| 31 | Predicates: []*eskip.Predicate{{Name: "Test", Args: []interface{}{3.14, "hello"}}}, |
| 32 | Filters: []*eskip.Filter{ |
| 33 | {Name: "filter0", Args: []interface{}{float64(3.1415), "argvalue"}}, |
| 34 | {Name: "filter1", Args: []interface{}{float64(-42), `ap"argvalue`}}}}, |
| 35 | incoming: &http.Request{ |
| 36 | Method: "OPTIONS", |
| 37 | RequestURI: "/testuri", |
| 38 | Proto: "HTTP/1.1", |
| 39 | Header: http.Header{"X-Test-Header": []string{"test-header-value"}}, |
| 40 | Host: "test.example.org", |
| 41 | RemoteAddr: "::1", |
| 42 | Body: io.NopCloser(bytes.NewBufferString("incoming body content"))}, |
| 43 | outgoing: &http.Request{ |
| 44 | Method: "HEAD", |
| 45 | RequestURI: "/testuri2", |
| 46 | Proto: "HTTP/1.1", |
| 47 | Header: http.Header{"X-Test-Header-2": []string{"test-header-value-2"}}, |
| 48 | Host: "www.example.org", |
| 49 | Body: io.NopCloser(bytes.NewBufferString("outgoing body content"))}, |
| 50 | response: &http.Response{ |
| 51 | StatusCode: http.StatusTeapot, |
| 52 | Header: http.Header{"X-Test-Response-Header": []string{"test-response-header-value"}}, |
| 53 | Body: io.NopCloser(bytes.NewBufferString("response body"))}}, |
| 54 | debugDocument{ |
| 55 | RouteId: "testRoute", |
| 56 | Route: (&eskip.Route{ |
| 57 | Path: "/hello", Backend: "https://www.example.org", |
| 58 | Predicates: []*eskip.Predicate{{Name: "Test", Args: []interface{}{3.14, "hello"}}}, |
| 59 | Filters: []*eskip.Filter{ |
| 60 | {Name: "filter0", Args: []interface{}{float64(3.1415), "argvalue"}}, |
| 61 | {Name: "filter1", Args: []interface{}{float64(-42), `ap"argvalue`}}}}).String(), |
| 62 | Predicates: []*eskip.Predicate{{Name: "Test", Args: []interface{}{3.14, "hello"}}}, |
| 63 | Filters: []*eskip.Filter{ |
| 64 | {Name: "filter0", Args: []interface{}{float64(3.1415), "argvalue"}}, |
| 65 | {Name: "filter1", Args: []interface{}{float64(-42), `ap"argvalue`}}}, |
| 66 | Incoming: &debugRequest{ |
| 67 | Method: "OPTIONS", |
| 68 | Uri: "/testuri", |
| 69 | Proto: "HTTP/1.1", |
| 70 | Header: http.Header{"X-Test-Header": []string{"test-header-value"}}, |
| 71 | Host: "test.example.org", |
| 72 | RemoteAddress: "::1"}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…