(t *testing.T)
| 254 | } |
| 255 | |
| 256 | func TestResponseHeaderHandler(t *testing.T) { |
| 257 | out := &bytes.Buffer{} |
| 258 | w := httptest.NewRecorder() |
| 259 | r := &http.Request{} |
| 260 | h := ResponseHeaderHandler("encoding", "Content-Encoding")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 261 | w.Header().Set("Content-Encoding", `gzip`) |
| 262 | w.WriteHeader(http.StatusOK) |
| 263 | })) |
| 264 | h2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 265 | h.ServeHTTP(w, r) |
| 266 | l := FromRequest(r) |
| 267 | l.Log().Msg("") |
| 268 | }) |
| 269 | h3 := NewHandler(zerolog.New(out))(h2) |
| 270 | h3.ServeHTTP(w, r) |
| 271 | if want, got := `{"encoding":"gzip"}`+"\n", decodeIfBinary(out); want != got { |
| 272 | t.Errorf("Invalid log output, got: %s, want: %s", got, want) |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | func TestProtoHandler(t *testing.T) { |
| 277 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected