-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountries_test.go
More file actions
93 lines (78 loc) · 2.28 KB
/
countries_test.go
File metadata and controls
93 lines (78 loc) · 2.28 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package igcclient
/*
func TestCountriesService_CountryByID(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/countries/1", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
w.Write([]byte("{\"Data\":{\"CountryId\":1},\"Success\":true,\"Errors\":[]}"))
})
country, err := client.Countries.CountryByID(1)
if err != nil {
t.Errorf(err.Error())
}
if *country.Data.CountryID != 1 {
t.Errorf("CountryID is not 1")
}
}
func TestCountriesService_CountriesTop(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/countries/top", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
w.Write([]byte("{\"Data\":[{\"CountryId\":1},{\"CountryId\":2}],\"Success\":true,\"Errors\":[]}"))
})
countries, err := client.Countries.CountriesTop()
if err != nil {
t.Errorf(err.Error())
}
if len(*countries.Data) != 2 {
t.Errorf("Expected 2 countries")
}
}
func TestCountriesService_CountryByAlphaCode2(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/countries/en", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
w.Write([]byte("{\"Data\":{\"CountryId\":1},\"Success\":true,\"Errors\":[]}"))
})
country, err := client.Countries.CountryByAlphaCode2("en")
if err != nil {
t.Errorf(err.Error())
}
if *country.Data.CountryID != 1 {
t.Errorf("CountryID is not 1")
}
}
func TestCountriesService_CountryByAlphaCode3(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/countries/eng", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
w.Write([]byte("{\"Data\":{\"CountryId\":1},\"Success\":true,\"Errors\":[]}"))
})
country, err := client.Countries.CountryByAlphaCode3("eng")
if err != nil {
t.Errorf(err.Error())
}
if *country.Data.CountryID != 1 {
t.Errorf("CountryID is not 1")
}
}
func TestCountriesService_Countries(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/countries", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
w.Write([]byte("{\"Data\":[{\"CountryId\":1},{\"CountryId\":2}],\"Success\":true,\"Errors\":[]}"))
})
countries, err := client.Countries.Countries()
if err != nil {
t.Errorf(err.Error())
}
if len(*countries.Data) != 2 {
t.Errorf("Expected 2 countries")
}
}
*/