-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcloud_test.go
More file actions
101 lines (88 loc) · 2.63 KB
/
cloud_test.go
File metadata and controls
101 lines (88 loc) · 2.63 KB
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
package service
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud"
)
const testFiHel1Zone string = "fi-hel1"
// TestGetZones tests that the GetZones() function returns proper data
func TestGetZones(t *testing.T) {
record(t, "getzones", func(ctx context.Context, t *testing.T, rec *recorder.Recorder, svc *Service) {
zones, err := svc.GetZones(ctx)
require.NoError(t, err)
assert.NotEmpty(t, zones.Zones)
var found bool
for _, z := range zones.Zones {
if z.Description == "Helsinki #1" && z.ID == testFiHel1Zone {
found = true
assert.True(t, z.Public.Bool())
break
}
}
assert.True(t, found)
})
}
// TestGetPriceZones tests that GetPriceZones() function returns proper data
func TestGetPriceZones(t *testing.T) {
record(t, "getpricezones", func(ctx context.Context, t *testing.T, rec *recorder.Recorder, svc *Service) {
zones, err := svc.GetPriceZones(ctx)
require.NoError(t, err)
assert.NotEmpty(t, zones.PriceZones)
var found bool
var zone upcloud.PriceZone
for _, z := range zones.PriceZones {
if z.Name == testFiHel1Zone {
found = true
zone = z
break
}
}
assert.True(t, found)
assert.NotZero(t, zone.Firewall.Amount)
assert.NotZero(t, zone.Firewall.Price)
assert.NotZero(t, zone.IPv4Address.Amount)
assert.NotZero(t, zone.IPv4Address.Price)
})
}
// TestGetTimeZones ensures that the GetTimeZones() function returns proper data
func TestGetTimeZones(t *testing.T) {
record(t, "gettimezones", func(ctx context.Context, t *testing.T, rec *recorder.Recorder, svc *Service) {
zones, err := svc.GetTimeZones(ctx)
require.NoError(t, err)
assert.NotEmpty(t, zones.TimeZones)
var found bool
for _, z := range zones.TimeZones {
if z == "Pacific/Wallis" {
found = true
break
}
}
assert.True(t, found)
})
}
// TestGetPlans ensures that the GetPlans() functions returns proper data
func TestGetPlans(t *testing.T) {
record(t, "getplans", func(ctx context.Context, t *testing.T, rec *recorder.Recorder, svc *Service) {
plans, err := svc.GetPlans(ctx)
require.NoError(t, err)
assert.NotEmpty(t, plans.Plans)
var found bool
var plan upcloud.Plan
for _, p := range plans.Plans {
if p.Name == "1xCPU-1GB" {
found = true
plan = p
break
}
}
assert.True(t, found)
assert.Equal(t, 1, plan.CoreNumber)
assert.Equal(t, 1024, plan.MemoryAmount)
assert.Equal(t, 1024, plan.PublicTrafficOut)
assert.Equal(t, 25, plan.StorageSize)
assert.Equal(t, upcloud.StorageTierMaxIOPS, plan.StorageTier)
})
}