(t *testing.T)
| 173 | } |
| 174 | |
| 175 | func TestRefererHandler(t *testing.T) { |
| 176 | out := &bytes.Buffer{} |
| 177 | r := &http.Request{ |
| 178 | Header: http.Header{ |
| 179 | "Referer": []string{"http://foo.com/bar"}, |
| 180 | }, |
| 181 | } |
| 182 | h := RefererHandler("referer")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 183 | l := FromRequest(r) |
| 184 | l.Log().Msg("") |
| 185 | })) |
| 186 | h = NewHandler(zerolog.New(out))(h) |
| 187 | h.ServeHTTP(nil, r) |
| 188 | if want, got := `{"referer":"http://foo.com/bar"}`+"\n", decodeIfBinary(out); want != got { |
| 189 | t.Errorf("Invalid log output, got: %s, want: %s", got, want) |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | func TestRequestIDHandler(t *testing.T) { |
| 194 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected