(t *testing.T)
| 107 | } |
| 108 | |
| 109 | func TestRemoteAddrHandlerIPv6(t *testing.T) { |
| 110 | out := &bytes.Buffer{} |
| 111 | r := &http.Request{ |
| 112 | RemoteAddr: "[2001:db8:a0b:12f0::1]:1234", |
| 113 | } |
| 114 | h := RemoteAddrHandler("ip")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 115 | l := FromRequest(r) |
| 116 | l.Log().Msg("") |
| 117 | })) |
| 118 | h = NewHandler(zerolog.New(out))(h) |
| 119 | h.ServeHTTP(nil, r) |
| 120 | if want, got := `{"ip":"[2001:db8:a0b:12f0::1]:1234"}`+"\n", decodeIfBinary(out); want != got { |
| 121 | t.Errorf("Invalid log output, got: %s, want: %s", got, want) |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | func TestRemoteIPHandler(t *testing.T) { |
| 126 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected