(t *testing.T)
| 42 | } |
| 43 | |
| 44 | func TestURLHandler(t *testing.T) { |
| 45 | out := &bytes.Buffer{} |
| 46 | r := &http.Request{ |
| 47 | URL: &url.URL{Path: "/path", RawQuery: "foo=bar"}, |
| 48 | } |
| 49 | h := URLHandler("url")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 50 | l := FromRequest(r) |
| 51 | l.Log().Msg("") |
| 52 | })) |
| 53 | h = NewHandler(zerolog.New(out))(h) |
| 54 | h.ServeHTTP(nil, r) |
| 55 | if want, got := `{"url":"/path?foo=bar"}`+"\n", decodeIfBinary(out); want != got { |
| 56 | t.Errorf("Invalid log output, got: %s, want: %s", got, want) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func TestMethodHandler(t *testing.T) { |
| 61 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected