(t *testing.T)
| 306 | } |
| 307 | |
| 308 | func TestCombinedHandlers(t *testing.T) { |
| 309 | out := &bytes.Buffer{} |
| 310 | r := &http.Request{ |
| 311 | Method: "POST", |
| 312 | URL: &url.URL{Path: "/path", RawQuery: "foo=bar"}, |
| 313 | } |
| 314 | h := MethodHandler("method")(RequestHandler("request")(URLHandler("url")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 315 | l := FromRequest(r) |
| 316 | l.Log().Msg("") |
| 317 | })))) |
| 318 | h = NewHandler(zerolog.New(out))(h) |
| 319 | h.ServeHTTP(nil, r) |
| 320 | if want, got := `{"method":"POST","request":"POST /path?foo=bar","url":"/path?foo=bar"}`+"\n", decodeIfBinary(out); want != got { |
| 321 | t.Errorf("Invalid log output, got: %s, want: %s", got, want) |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | func BenchmarkHandlers(b *testing.B) { |
| 326 | r := &http.Request{ |
nothing calls this directly
no test coverage detected