pkg/geoloc: remove static country definition

This commit is contained in:
Tom Neuber 2024-01-28 10:52:14 +01:00
parent 192d54465f
commit bd2962ef77
Signed by: tom
GPG key ID: F17EFE4272D89FF6
3 changed files with 0 additions and 1522 deletions

View file

@ -4,18 +4,10 @@ import (
"fmt"
"math"
"net"
"strings"
"github.com/praserx/ipconv"
)
func GetCountry(input string) *IPInfo {
if c, exists := countries[strings.ToUpper(input)]; exists {
return &c
}
return nil
}
func GetIPInfo(ipaddress string) (uint, error) {
ip := net.ParseIP(ipaddress)
if ip == nil {

File diff suppressed because it is too large Load diff

View file

@ -5,33 +5,6 @@ import (
"testing"
)
func TestGetCountry(t *testing.T) {
type args struct {
input string
}
tests := []struct {
name string
args args
want *IPInfo
}{
{"GBR Test", args{input: "826"}, nil},
{"USA upper Test", args{input: "USA"}, nil},
{"Nothing Test", args{input: ""}, nil},
{"Åland Islands Test", args{input: "Aland Islands"}, nil},
{"Bahreïn Test", args{input: "Bahreïn"}, nil},
{"Bahreïn Test (FR)", args{input: "Bahrein"}, nil},
{"USA uppter Test", args{input: "US"}, GetCountry("US")},
{"USA lower Test", args{input: "us"}, GetCountry("US")},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetCountry(tt.args.input); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetCountry() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetIPInfo(t *testing.T) {
type args struct {
input string