forked from equinixmetal-archive/packngo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
capacities_test.go
58 lines (49 loc) · 1.03 KB
/
capacities_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
package packngo
import (
"fmt"
"testing"
)
func TestAccCheckCapacity(t *testing.T) {
skipUnlessAcceptanceTestsAllowed(t)
c, stopRecord := setup(t)
defer stopRecord()
input := &CapacityInput{
[]ServerInfo{
{
Facility: "ams1",
Plan: testPlan(),
Quantity: 1},
},
}
cap, _, err := c.CapacityService.Check(input)
if err != nil {
t.Fatal(err)
}
for _, s := range cap.Servers {
if !s.Available {
t.Fatal(fmt.Errorf("capacity of %d servers should have been available", input.Servers[0].Quantity))
break
}
}
list, _, err := c.CapacityService.List()
if err != nil {
t.Fatal(err)
}
for k, v := range *list {
if v["baremetal_2a2"].Level == "unavailable" {
input.Servers[0].Plan = "baremetal_2a2"
input.Servers[0].Facility = k
break
}
}
cap, _, err = c.CapacityService.Check(input)
if err != nil {
t.Fatal(err)
}
for _, s := range cap.Servers {
if s.Available {
t.Fatal(fmt.Errorf("capacity of %d servers should not have been available", input.Servers[0].Quantity))
break
}
}
}