Fixed minor code style in PR

- Fixed minor coding style in PR
- Updated geoip list
This commit is contained in:
Toby Chui
2024-05-06 18:50:12 +08:00
parent 1db2ca61fa
commit 46817d0664
10 changed files with 80305 additions and 88686 deletions

View File

@@ -51,8 +51,29 @@ func TestResolveCountryCodeFromIP(t *testing.T) {
}
// Test an IP address that should return a valid country code
ip := "8.8.8.8"
expected := "US"
knownIpCountryMap := [][]string{
{"3.224.220.101", "US"},
{"176.113.115.113", "RU"},
{"65.21.233.213", "FI"},
{"94.23.207.193", "FR"},
}
for _, testcase := range knownIpCountryMap {
ip := testcase[0]
expected := testcase[1]
info, err := store.ResolveCountryCodeFromIP(ip)
if err != nil {
t.Errorf("error resolving country code for IP %s: %v", ip, err)
return
}
if info.CountryIsoCode != expected {
t.Errorf("expected country code %s, but got %s for IP %s", expected, info.CountryIsoCode, ip)
}
}
// Test an IP address that should return an empty country code
ip := "127.0.0.1"
expected := ""
info, err := store.ResolveCountryCodeFromIP(ip)
if err != nil {
t.Errorf("error resolving country code for IP %s: %v", ip, err)
@@ -61,16 +82,4 @@ func TestResolveCountryCodeFromIP(t *testing.T) {
if info.CountryIsoCode != expected {
t.Errorf("expected country code %s, but got %s for IP %s", expected, info.CountryIsoCode, ip)
}
// Test an IP address that should return an empty country code
ip = "127.0.0.1"
expected = ""
info, err = store.ResolveCountryCodeFromIP(ip)
if err != nil {
t.Errorf("error resolving country code for IP %s: %v", ip, err)
return
}
if info.CountryIsoCode != expected {
t.Errorf("expected country code %s, but got %s for IP %s", expected, info.CountryIsoCode, ip)
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff