-
Notifications
You must be signed in to change notification settings - Fork 14
/
serverdisks_test.go
97 lines (76 loc) · 2.59 KB
/
serverdisks_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
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
package glesys
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestServerDisk_Create(t *testing.T) {
c := &mockClient{body: `{ "response": { "disk": { "id": "aaaaa-bbbbbb-cccccc",
"sizeingib": 200,
"name": "Diskett",
"scsiid": 1,
"type": "gold"
}}}`}
s := ServerDisksService{client: c}
params := CreateServerDiskParams{
ServerID: "wps123456",
Name: "Diskett",
SizeInGIB: 200,
}
disk, _ := s.Create(context.Background(), params)
assert.Equal(t, "serverdisk/create", c.lastPath, "correct path is used")
assert.Equal(t, 200, disk.SizeInGIB, "size is correct")
assert.Equal(t, "Diskett", disk.Name, "correct name variable")
assert.Equal(t, "gold", disk.Type, "correct type variable")
}
func TestServerDisk_UpdateName(t *testing.T) {
c := &mockClient{body: `{ "response": { "disk": { "id": "aaaaa-bbbbbb-cccccc",
"sizeingib": 200,
"name": "Extradisk",
"scsiid": 1
}}}`}
s := ServerDisksService{client: c}
params := EditServerDiskParams{
ID: "aaaaa-bbbbbb-cccccc",
Name: "Extradisk",
}
disk, _ := s.UpdateName(context.Background(), params)
assert.Equal(t, "serverdisk/updatename", c.lastPath, "correct path is used")
assert.Equal(t, 200, disk.SizeInGIB, "size is correct")
assert.Equal(t, "Extradisk", disk.Name, "correct name variable")
}
func TestServerDisk_Reconfigure(t *testing.T) {
c := &mockClient{body: `{ "response": { "disk": { "id": "aaaaa-bbbbbb-cccccc",
"sizeingib": 250,
"name": "Diskett",
"scsiid": 1
}}}`}
s := ServerDisksService{client: c}
params := EditServerDiskParams{
ID: "aaaaa-bbbbbb-cccccc",
SizeInGIB: 250,
}
disk, _ := s.Reconfigure(context.Background(), params)
assert.Equal(t, "serverdisk/reconfigure", c.lastPath, "correct path is used")
assert.Equal(t, 250, disk.SizeInGIB, "size is correct")
assert.Equal(t, "Diskett", disk.Name, "correct name variable")
}
func TestServerDisk_Delete(t *testing.T) {
c := &mockClient{}
s := ServerDisksService{client: c}
id := "aaaaa-bbbbbb-cccccc"
_ = s.Delete(context.Background(), id)
assert.Equal(t, "serverdisk/delete", c.lastPath, "correct path is used")
}
func TestServerDisk_Limits(t *testing.T) {
c := &mockClient{body: `{ "response": { "limits": { "minsizeingib": 10,
"maxsizeingib": 1024,
"currentnumdisks": 1,
"maxnumdisks": 3
}}}`}
s := ServerDisksService{client: c}
limits, _ := s.Limits(context.Background(), "wps12345")
assert.Equal(t, "serverdisk/limits", c.lastPath, "correct path is used")
assert.Equal(t, 1024, limits.MaxSizeInGIB, "max size is correct")
assert.Equal(t, 3, limits.MaxNumDisks, "max number of disks correct")
}