1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 21:30:49 +00:00

Merge pull request #3560 from JessonChan/develop

TestToJson bug fixed
This commit is contained in:
astaxie 2019-03-08 00:18:39 +08:00 committed by GitHub
commit c2b6cb5c3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -206,10 +206,16 @@ func TestToJson(t *testing.T) {
t.Fatal(err)
}
t.Log(ip.Origin)
if n := strings.Count(ip.Origin, "."); n != 3 {
ips := strings.Split(ip.Origin, ",")
if len(ips) == 0 {
t.Fatal("response is not valid ip")
}
for i := range ips {
if net.ParseIP(strings.TrimSpace(ips[i])).To4() == nil {
t.Fatal("response is not valid ip")
}
}
}
func TestToFile(t *testing.T) {