forked from civo/civogo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
region_test.go
43 lines (38 loc) · 1.59 KB
/
region_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
package civogo
import (
"testing"
)
func TestListRegions(t *testing.T) {
client, server, _ := NewClientForTesting(map[string]string{
"/v2/regions": `[{"code":"NYC1","name":"New York 1","type":"civostack","out_of_capacity":false,"country":"us","country_name":"United States","features":{"iaas":false,"kubernetes":true}},{"code":"SVG1","name":"Stevenage 1","default":true,"type":"openstack","out_of_capacity":true,"country":"uk","country_name":"United Kingdom","features":{"iaas":true,"kubernetes":true}}]`,
})
defer server.Close()
got, err := client.ListRegions()
if err != nil {
t.Errorf("Request returned an error: %s", err)
return
}
if got[0].Code != "NYC1" {
t.Errorf("Expected %s, got %s", "NYC1", got[0].Code)
}
if got[0].Name != "New York 1" {
t.Errorf("Expected %s, got %s", "New York 1", got[0].Name)
}
}
func TestFindRegions(t *testing.T) {
client, server, _ := NewClientForTesting(map[string]string{
"/v2/regions": `[{"code":"NYC1","name":"New York 1","type":"civostack","out_of_capacity":false,"country":"us","country_name":"United States","features":{"iaas":false,"kubernetes":true}},{"code":"SVG1","name":"Stevenage 1","default":true,"type":"openstack","out_of_capacity":true,"country":"uk","country_name":"United Kingdom","features":{"iaas":true,"kubernetes":true}}]`,
})
defer server.Close()
got, err := client.FindRegion("nyc1")
if err != nil {
t.Errorf("Request returned an error: %s", err)
return
}
if got.Code != "NYC1" {
t.Errorf("Expected %s, got %s", "NYC1", got.Code)
}
if got.Name != "New York 1" {
t.Errorf("Expected %s, got %s", "New York 1", got.Name)
}
}