(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func TestRemoteIPHandlerIPv6(t *testing.T) { |
| 142 | out := &bytes.Buffer{} |
| 143 | r := &http.Request{ |
| 144 | RemoteAddr: "[2001:db8:a0b:12f0::1]:1234", |
| 145 | } |
| 146 | h := RemoteIPHandler("ip")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 147 | l := FromRequest(r) |
| 148 | l.Log().Msg("") |
| 149 | })) |
| 150 | h = NewHandler(zerolog.New(out))(h) |
| 151 | h.ServeHTTP(nil, r) |
| 152 | if want, got := `{"ip":"2001:db8:a0b:12f0::1"}`+"\n", decodeIfBinary(out); want != got { |
| 153 | t.Errorf("Invalid log output, got: %s, want: %s", got, want) |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | func TestUserAgentHandler(t *testing.T) { |
| 158 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected