refactor for unit tests

This commit is contained in:
Notealot 2021-10-25 22:31:30 +08:00
parent cab1bb9a40
commit e540fcfeb6

View File

@ -12,6 +12,7 @@ import (
"html/template" "html/template"
"io" "io"
"mime/multipart" "mime/multipart"
"net"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
@ -2051,7 +2052,8 @@ func TestRemoteIPFail(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder()) c, _ := CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest("POST", "/", nil) c.Request, _ = http.NewRequest("POST", "/", nil)
c.Request.RemoteAddr = "[:::]:80" c.Request.RemoteAddr = "[:::]:80"
ip, trust := c.RemoteIP() ip := net.ParseIP(c.RemoteIP())
trust := c.engine.isTrustedProxy(ip)
assert.Nil(t, ip) assert.Nil(t, ip)
assert.False(t, trust) assert.False(t, trust)
} }