(t *testing.T)
| 74 | } |
| 75 | |
| 76 | func TestRequestHandler(t *testing.T) { |
| 77 | out := &bytes.Buffer{} |
| 78 | r := &http.Request{ |
| 79 | Method: "POST", |
| 80 | URL: &url.URL{Path: "/path", RawQuery: "foo=bar"}, |
| 81 | } |
| 82 | h := RequestHandler("request")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 83 | l := FromRequest(r) |
| 84 | l.Log().Msg("") |
| 85 | })) |
| 86 | h = NewHandler(zerolog.New(out))(h) |
| 87 | h.ServeHTTP(nil, r) |
| 88 | if want, got := `{"request":"POST /path?foo=bar"}`+"\n", decodeIfBinary(out); want != got { |
| 89 | t.Errorf("Invalid log output, got: %s, want: %s", got, want) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | func TestRemoteAddrHandler(t *testing.T) { |
| 94 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected