(t *testing.T)
| 91 | } |
| 92 | |
| 93 | func TestRemoteAddrHandler(t *testing.T) { |
| 94 | out := &bytes.Buffer{} |
| 95 | r := &http.Request{ |
| 96 | RemoteAddr: "1.2.3.4:1234", |
| 97 | } |
| 98 | h := RemoteAddrHandler("ip")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 99 | l := FromRequest(r) |
| 100 | l.Log().Msg("") |
| 101 | })) |
| 102 | h = NewHandler(zerolog.New(out))(h) |
| 103 | h.ServeHTTP(nil, r) |
| 104 | if want, got := `{"ip":"1.2.3.4:1234"}`+"\n", decodeIfBinary(out); want != got { |
| 105 | t.Errorf("Invalid log output, got: %s, want: %s", got, want) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func TestRemoteAddrHandlerIPv6(t *testing.T) { |
| 110 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected