test: add more tests (#1150)
This commit is contained in:
@@ -10,5 +10,6 @@ func GetRemoteAddr(r *http.Request) string {
|
||||
if len(v) > 0 {
|
||||
return v
|
||||
}
|
||||
|
||||
return r.RemoteAddr
|
||||
}
|
||||
|
||||
@@ -16,3 +16,10 @@ func TestGetRemoteAddr(t *testing.T) {
|
||||
r.Header.Set(xForwardedFor, host)
|
||||
assert.Equal(t, host, GetRemoteAddr(r))
|
||||
}
|
||||
|
||||
func TestGetRemoteAddrNoHeader(t *testing.T) {
|
||||
r, err := http.NewRequest(http.MethodGet, "/", strings.NewReader(""))
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.True(t, len(GetRemoteAddr(r)) == 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user