forked from equinixmetal-archive/packngo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plans_test.go
43 lines (36 loc) · 811 Bytes
/
plans_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 packngo
import (
"log"
"testing"
)
func TestAccPlans(t *testing.T) {
skipUnlessAcceptanceTestsAllowed(t)
c := setup(t)
l, _, err := c.Plans.List(&ListOptions{Includes: []string{"available_in"}})
avail := map[string][]string{}
for _, p := range l {
for _, f := range p.AvailableIn {
if _, ok := avail[f.Code]; !ok {
avail[f.Code] = []string{p.Slug}
} else {
avail[f.Code] = append(avail[f.Code], p.Slug)
}
}
if p.Pricing.Hour > 0.0 {
t.Fatalf("strange pricing for %+v", p)
}
}
for f, ps := range avail {
if len(ps) == 0 {
t.Fatalf("no plans available in facility %s", f)
}
// prints plans available in facility
log.Printf("%s: %+v\n", f, ps)
}
if len(l) == 0 {
t.Fatal("Empty plans listing from the API")
}
if err != nil {
t.Fatal(err)
}
}