(t *testing.T)
| 155 | } |
| 156 | |
| 157 | func TestUserAgentHandler(t *testing.T) { |
| 158 | out := &bytes.Buffer{} |
| 159 | r := &http.Request{ |
| 160 | Header: http.Header{ |
| 161 | "User-Agent": []string{"some user agent string"}, |
| 162 | }, |
| 163 | } |
| 164 | h := UserAgentHandler("ua")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 165 | l := FromRequest(r) |
| 166 | l.Log().Msg("") |
| 167 | })) |
| 168 | h = NewHandler(zerolog.New(out))(h) |
| 169 | h.ServeHTTP(nil, r) |
| 170 | if want, got := `{"ua":"some user agent string"}`+"\n", decodeIfBinary(out); want != got { |
| 171 | t.Errorf("Invalid log output, got: %s, want: %s", got, want) |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | func TestRefererHandler(t *testing.T) { |
| 176 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected