@@ -8,15 +8,18 @@ func TestListInstanceSizes(t *testing.T) {
8
8
client , server , _ := NewClientForTesting (map [string ]string {
9
9
"/v2/sizes" : `[
10
10
{
11
- "id": "d6b170f2-d2b3-4205-84c4-61898622393d",
12
- "name": "micro",
13
- "nice_name": "Micro",
14
- "cpu_cores": 1,
15
- "ram_mb": 1024,
16
- "disk_gb": 25,
17
- "description": "Micro - 1GB RAM, 1 CPU Core, 25GB SSD Disk",
18
- "selectable": true
19
- }
11
+ "type": "Instance",
12
+ "name": "g4s.xsmall",
13
+ "nice_name": "xSmall - Standard",
14
+ "cpu_cores": 1,
15
+ "gpu_count": 0,
16
+ "gpu_type": "",
17
+ "ram_mb": 1024,
18
+ "disk_gb": 25,
19
+ "transfer_tb": 1,
20
+ "description": "xSmall - Standard",
21
+ "selectable": true
22
+ }
20
23
]
21
24
` ,
22
25
})
@@ -27,17 +30,14 @@ func TestListInstanceSizes(t *testing.T) {
27
30
t .Errorf ("Request returned an error: %s" , err )
28
31
return
29
32
}
30
- if got [0 ].ID != "d6b170f2-d2b3-4205-84c4-61898622393d " {
31
- t .Errorf ("Expected %s, got %s" , "d6b170f2-d2b3-4205-84c4-61898622393d " , got [0 ].ID )
33
+ if got [0 ].Name != "g4s.xsmall " {
34
+ t .Errorf ("Expected %s, got %s" , "g4s.xsmall " , got [0 ].Name )
32
35
}
33
- if got [0 ].Name != "micro " {
34
- t .Errorf ("Expected %s, got %s" , "micro " , got [0 ].Name )
36
+ if got [0 ].Type != "Instance " {
37
+ t .Errorf ("Expected %s, got %s" , "Instance " , got [0 ].Type )
35
38
}
36
- if got [0 ].NiceName != "Micro" {
37
- t .Errorf ("Expected %s, got %s" , "Micro" , got [0 ].NiceName )
38
- }
39
- if got [0 ].NiceName != "Micro" {
40
- t .Errorf ("Expected %s, got %s" , "Micro" , got [0 ].NiceName )
39
+ if got [0 ].NiceName != "xSmall - Standard" {
40
+ t .Errorf ("Expected %s, got %s" , "xSmall - Standard" , got [0 ].NiceName )
41
41
}
42
42
if ! got [0 ].Selectable {
43
43
t .Errorf ("Expected first result to be selectable" )
@@ -51,66 +51,52 @@ func TestListInstanceSizes(t *testing.T) {
51
51
if got [0 ].DiskGigabytes != 25 {
52
52
t .Errorf ("Expected %d, got %d" , 25 , got [0 ].DiskGigabytes )
53
53
}
54
- if got [0 ].Description != "Micro - 1GB RAM, 1 CPU Core, 25GB SSD Disk " {
55
- t .Errorf ("Expected %s, got %s" , "Micro - 1GB RAM, 1 CPU Core, 25GB SSD Disk " , got [0 ].Description )
54
+ if got [0 ].Description != "xSmall - Standard " {
55
+ t .Errorf ("Expected %s, got %s" , "xSmall - Standard " , got [0 ].Description )
56
56
}
57
57
}
58
58
59
59
func TestFindInstanceSizes (t * testing.T ) {
60
60
client , server , _ := NewClientForTesting (map [string ]string {
61
61
"/v2/sizes" : `[
62
62
{
63
- "id": "d6b170f2-d2b3-4205-84c4-61898622393d",
64
- "name": "debian-10",
65
- "nice_name": "Debian 10",
66
- "cpu_cores": 1,
67
- "ram_mb": 1024,
68
- "disk_gb": 25,
69
- "description": "Micro - 1GB RAM, 1 CPU Core, 25GB SSD Disk",
70
- "selectable": true
71
- },
72
- {
73
- "id": "456780f2-d3b3-345-84c4-12345622393d",
74
- "name": "debian-9",
75
- "nice_name": "Debian 9",
76
- "cpu_cores": 1,
77
- "ram_mb": 2024,
78
- "disk_gb": 50,
79
- "description": "Debian - 2GB RAM, 1 CPU Core, 50GB SSD Disk",
80
- "selectable": true
81
- }
63
+ "type": "Instance",
64
+ "name": "g3.xsmall",
65
+ "nice_name": "Extra Small",
66
+ "cpu_cores": 1,
67
+ "gpu_count": 0,
68
+ "gpu_type": "",
69
+ "ram_mb": 1024,
70
+ "disk_gb": 25,
71
+ "transfer_tb": 1,
72
+ "description": "Extra Small",
73
+ "selectable": true
74
+ },
75
+ {
76
+ "type": "Instance",
77
+ "name": "g3.small",
78
+ "nice_name": "Small",
79
+ "cpu_cores": 1,
80
+ "gpu_count": 0,
81
+ "gpu_type": "",
82
+ "ram_mb": 2048,
83
+ "disk_gb": 25,
84
+ "transfer_tb": 2,
85
+ "description": "Small",
86
+ "selectable": true
87
+ }
82
88
]
83
89
` ,
84
90
})
85
91
defer server .Close ()
86
92
87
- got , _ := client .FindInstanceSizes ("456780f2" )
88
- if got .ID != "456780f2-d3b3-345-84c4-12345622393d" {
89
- t .Errorf ("Expected %s, got %s" , "456780f2-d3b3-345-84c4-12345622393d" , got .ID )
90
- }
91
-
92
- got , _ = client .FindInstanceSizes ("d6b170" )
93
- if got .ID != "d6b170f2-d2b3-4205-84c4-61898622393d" {
94
- t .Errorf ("Expected %s, got %s" , "d6b170f2-d2b3-4205-84c4-61898622393d" , got .ID )
95
- }
96
-
97
- got , _ = client .FindInstanceSizes ("debian-1" )
98
- if got .ID != "d6b170f2-d2b3-4205-84c4-61898622393d" {
99
- t .Errorf ("Expected %s, got %s" , "d6b170f2-d2b3-4205-84c4-61898622393d" , got .ID )
100
- }
101
-
102
- got , _ = client .FindInstanceSizes ("debian-9" )
103
- if got .ID != "456780f2-d3b3-345-84c4-12345622393d" {
104
- t .Errorf ("Expected %s, got %s" , "456780f2-d3b3-345-84c4-12345622393d" , got .ID )
105
- }
106
-
107
- _ , err := client .FindInstanceSizes ("debian" )
108
- if err .Error () != "MultipleMatchesError: unable to find debian because there were multiple matches" {
109
- t .Errorf ("Expected %s, got %s" , "unable to find com because there were multiple matches" , err .Error ())
93
+ got , _ := client .FindInstanceSizes ("g3.small" )
94
+ if got .Name != "g3.small" {
95
+ t .Errorf ("Expected %s, got %s" , "g3.small" , got .Name )
110
96
}
111
97
112
- _ , err = client .FindInstanceSizes ("missing " )
113
- if err . Error () != "ZeroMatchesError: unable to find missing, zero matches " {
114
- t .Errorf ("Expected %s, got %s" , "unable to find missing, zero matches " , err . Error () )
98
+ got , _ = client .FindInstanceSizes ("xsmall " )
99
+ if got . Name != "g3.xsmall " {
100
+ t .Errorf ("Expected %s, got %s" , "g3.xsmall " , got . Name )
115
101
}
116
102
}
0 commit comments