-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgeoip_test.go
35 lines (33 loc) · 968 Bytes
/
geoip_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"net"
"testing"
)
func TestInitGeoipReader(t *testing.T) {
tests := []string{
"23.78.102.25",
"2600:141b:9000:0586:0000:0000:0000:24fe",
"2600:141b:9000:05ae:0000:0000:0000:24fe",
"119.96.90.251",
}
InitGeoipReader("")
for _, tt := range tests {
t.Run("geoIP", func(t *testing.T) {
country, state, city := GeoIPCountryStateCity(net.ParseIP(tt))
t.Logf("ip %v country: %v, state: %v, city: %v", tt, country, state, city)
})
}
for _, tt := range tests {
t.Run("geoIP", func(t *testing.T) {
country, state, city := GeoIPCountryStateCity(net.ParseIP(tt))
t.Logf("ip %v country: %v, state: %v, city: %v", tt, country, state, city)
})
}
InitGeoipReader("/usr/local/var/GeoIP/dbip-city.mmdb")
for _, tt := range tests {
t.Run("geoIP", func(t *testing.T) {
country, state, city := GeoIPCountryStateCity(net.ParseIP(tt))
t.Logf("ip %v country: %v, state: %v, city: %v", tt, country, state, city)
})
}
}