pkg/geoloc: remove static country definition
This commit is contained in:
parent
cfbad73d1e
commit
2ca426ee4e
3 changed files with 0 additions and 1522 deletions
|
@ -4,18 +4,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/praserx/ipconv"
|
"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) {
|
func GetIPInfo(ipaddress string) (uint, error) {
|
||||||
ip := net.ParseIP(ipaddress)
|
ip := net.ParseIP(ipaddress)
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,33 +5,6 @@ import (
|
||||||
"testing"
|
"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) {
|
func TestGetIPInfo(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
input string
|
input string
|
||||||
|
|
Loading…
Reference in a new issue