-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
47 lines (40 loc) · 1.17 KB
/
main_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
36
37
38
39
40
41
42
43
44
45
46
47
package goip
import "testing"
//you need to set the username and license to run the tests
var userName = "101479"
var license = "LLrtcBQcPkkT"
func TestConnect(t *testing.T) {
New(userName, license)
}
func TestCountryName(t *testing.T) {
check := New(userName, license)
country, err := check.CountryName("80.249.82.222")
if err != nil {
t.Error("Can't resolve IP to Country\n", err)
} else if country != "Belarus" {
t.Error("Incorrect IP to Country (expected Belarus)", country)
}
}
func TestCountryNameFail(t *testing.T) {
check := New(userName, license)
_, err := check.CountryName("not-exists")
if err == nil {
t.Error("Error not produced for the invalid input")
}
}
func TestContinentName(t *testing.T) {
check := New(userName, license)
continent, err := check.ContinentName("80.249.82.222")
if err != nil {
t.Error("Can't resolve IP to Continent\n", err)
} else if continent != "Europe" {
t.Error("Incorrect IP to Continent (expected Europe)", continent)
}
}
func TestContinentNameFail(t *testing.T) {
check := New(userName, license)
_, err := check.ContinentName("not-exists")
if err == nil {
t.Error("Error not produced for the invalid input")
}
}