-
Notifications
You must be signed in to change notification settings - Fork 1
/
address_test.go
152 lines (129 loc) · 2.79 KB
/
address_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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package novapost_test
import (
. "github.com/sirkostya009/go-novapost"
"os"
"testing"
)
const (
KyivSettlementRef = "0db2df4b-4b3a-11e4-ab6d-005056801329"
KyivCityRef = "8d5a980d-391c-11dd-90d9-001a92567626"
)
var c = NewClient(os.Getenv("NOVA_POST_API_KEY"))
func TestSearchSettlements(t *testing.T) {
settlements, err := c.SearchSettlements(SettlementRequest{
CityName: "Київ",
Limit: 150,
Page: 1,
})
if err != nil {
t.Error(err)
}
if !settlements.Success {
t.Log("No settlements found", settlements)
}
}
func TestSearchSettlementStreets(t *testing.T) {
streets, err := c.SearchSettlementStreets(SettlementStreetRequest{
StreetName: "Хрещатик",
SettlementRef: KyivSettlementRef,
Page: 1,
})
if err != nil {
t.Error(err)
}
if !streets.Success {
t.Log("No streets found", streets)
}
}
func TestGetSettlements(t *testing.T) {
settlements, err := c.GetSettlements(GetSettlementsRequest{
FindByString: "Київ",
Limit: 150,
Page: 1,
})
if err != nil {
t.Error(err)
}
if !settlements.Success {
t.Log("No settlements found", settlements)
}
}
func TestGetCities(t *testing.T) {
cities, err := c.GetCities(CityRequest{
FindByString: "Київ",
Limit: 150,
Page: 1,
})
if err != nil {
t.Error(err)
}
if !cities.Success {
t.Log("No cities found", cities)
}
}
func TestGetAreas(t *testing.T) {
areas, err := c.GetAreas()
if err != nil {
t.Error(err)
}
if !areas.Success {
t.Log("No areas found", areas)
}
}
func TestGetWarehouses(t *testing.T) {
warehouses, err := c.GetWarehouses(WarehouseRequest{
CityName: "Київ",
Limit: 150,
Page: 1,
})
if err != nil {
t.Error(err)
}
if !warehouses.Success {
t.Log("No warehouses found", warehouses)
}
}
func TestGetWarehouseTypes(t *testing.T) {
warehouseTypes, err := c.GetWarehouseTypes()
if err != nil {
t.Error(err)
}
if !warehouseTypes.Success {
t.Log("No warehouse types found", warehouseTypes)
}
}
func TestGetStreet(t *testing.T) {
street, err := c.GetStreet(StreetRequest{
CityRef: KyivCityRef,
Limit: 150,
Page: 1,
})
if err != nil {
t.Error(err)
}
if !street.Success {
t.Log("No streets found", street)
}
}
func TestGetSettlementCountryRegion(t *testing.T) {
settlementCountryRegion, err := c.GetSettlementCountryRegion(AreaRef{
AreaRef: "7150813e-9b87-11de-822f-000c2965ae0e",
})
if err != nil {
t.Error(err)
}
if !settlementCountryRegion.Success {
t.Log("No settlement country regions found", settlementCountryRegion)
}
}
func TestGetSettlementAreas(t *testing.T) {
settlementAreas, err := c.GetSettlementAreas(Ref{
Ref: KyivSettlementRef,
})
if err != nil {
t.Error(err)
}
if !settlementAreas.Success {
t.Log("No settlement areas found", settlementAreas)
}
}