country-geo-locations/pkg/geoloc/main_test.go

34 lines
824 B
Go
Raw Normal View History

package geoloc
import (
"reflect"
"testing"
)
func TestGetCountry(t *testing.T) {
type args struct {
input string
}
tests := []struct {
name string
args args
want *Country
}{
{"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)
}
})
}
}