-
Notifications
You must be signed in to change notification settings - Fork 434
/
disk_test.go
57 lines (45 loc) · 1.15 KB
/
disk_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
package gcpcomputepricing
import "testing"
func TestGetPDStandardPrice(t *testing.T) {
monthlyRate := diskGetter(t, Standard, 20)
if monthlyRate != 880000000 {
t.Errorf("Monthly rate should be 880000000, instead of %d", monthlyRate)
}
}
func TestGetPDBalancedPrice(t *testing.T) {
monthlyRate := diskGetter(t, Balanced, 50)
if monthlyRate != 5500000000 {
t.Errorf("Monthly rate should be 5500000000, instead of %d", monthlyRate)
}
}
func TestGetPDSSDPrice(t *testing.T) {
monthlyRate := diskGetter(t, SSD, 100)
if monthlyRate != 18700000000 {
t.Errorf("Monthly rate should be 18700000000, instead of %d", monthlyRate)
}
}
func TestGetPDExtremePrice(t *testing.T) {
monthlyRate := diskGetter(t, SSD, 150)
if monthlyRate != 28050000000 {
t.Errorf("Monthly rate should be 28050000000, instead of %d", monthlyRate)
}
}
func diskGetter(t *testing.T, diskType string, diskSize uint64) uint64 {
p, err := Fetch()
if err != nil {
t.Fatal(err)
}
monthlyRate, err := getDiskMonthly(
p,
Opts{
Region: "europe-north1",
Type: diskType,
DiskSize: diskSize,
},
typeDiskGet,
)
if err != nil {
t.Fatal(err)
}
return monthlyRate
}