-
Notifications
You must be signed in to change notification settings - Fork 24
/
instance_size_test.go
102 lines (96 loc) · 2.43 KB
/
instance_size_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
package civogo
import (
"testing"
)
func TestListInstanceSizes(t *testing.T) {
client, server, _ := NewClientForTesting(map[string]string{
"/v2/sizes": `[
{
"type": "Instance",
"name": "g4s.xsmall",
"nice_name": "xSmall - Standard",
"cpu_cores": 1,
"gpu_count": 0,
"gpu_type": "",
"ram_mb": 1024,
"disk_gb": 25,
"transfer_tb": 1,
"description": "xSmall - Standard",
"selectable": true
}
]
`,
})
defer server.Close()
got, err := client.ListInstanceSizes()
if err != nil {
t.Errorf("Request returned an error: %s", err)
return
}
if got[0].Name != "g4s.xsmall" {
t.Errorf("Expected %s, got %s", "g4s.xsmall", got[0].Name)
}
if got[0].Type != "Instance" {
t.Errorf("Expected %s, got %s", "Instance", got[0].Type)
}
if got[0].NiceName != "xSmall - Standard" {
t.Errorf("Expected %s, got %s", "xSmall - Standard", got[0].NiceName)
}
if !got[0].Selectable {
t.Errorf("Expected first result to be selectable")
}
if got[0].CPUCores != 1 {
t.Errorf("Expected %d, got %d", 1, got[0].CPUCores)
}
if got[0].RAMMegabytes != 1024 {
t.Errorf("Expected %d, got %d", 1024, got[0].RAMMegabytes)
}
if got[0].DiskGigabytes != 25 {
t.Errorf("Expected %d, got %d", 25, got[0].DiskGigabytes)
}
if got[0].Description != "xSmall - Standard" {
t.Errorf("Expected %s, got %s", "xSmall - Standard", got[0].Description)
}
}
func TestFindInstanceSizes(t *testing.T) {
client, server, _ := NewClientForTesting(map[string]string{
"/v2/sizes": `[
{
"type": "Instance",
"name": "g3.xsmall",
"nice_name": "Extra Small",
"cpu_cores": 1,
"gpu_count": 0,
"gpu_type": "",
"ram_mb": 1024,
"disk_gb": 25,
"transfer_tb": 1,
"description": "Extra Small",
"selectable": true
},
{
"type": "Instance",
"name": "g3.small",
"nice_name": "Small",
"cpu_cores": 1,
"gpu_count": 0,
"gpu_type": "",
"ram_mb": 2048,
"disk_gb": 25,
"transfer_tb": 2,
"description": "Small",
"selectable": true
}
]
`,
})
defer server.Close()
got, _ := client.FindInstanceSizes("g3.small")
if got.Name != "g3.small" {
t.Errorf("Expected %s, got %s", "g3.small", got.Name)
}
got, _ = client.FindInstanceSizes("xsmall")
if got.Name != "g3.xsmall" {
t.Errorf("Expected %s, got %s", "g3.xsmall", got.Name)
}
}