-
Notifications
You must be signed in to change notification settings - Fork 2
/
servers_default_test.go
121 lines (109 loc) · 2.22 KB
/
servers_default_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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Code generated by go generate; DO NOT EDIT.
package brightbox
import (
"path"
"testing"
"time"
"gotest.tools/v3/assert"
)
func TestServers(t *testing.T) {
instance := testAll(
t,
(*Client).Servers,
"Server",
"servers",
"Servers",
)
assert.Equal(t, instance.ID, "srv-lv426")
}
func TestServer(t *testing.T) {
instance := testInstance(
t,
(*Client).Server,
"Server",
path.Join("servers", "srv-lv426"),
"server",
"srv-lv426",
)
assert.Equal(t, instance.ID, "srv-lv426")
}
func TestCreateServer(t *testing.T) {
newResource := ServerOptions{}
instance := testModify(
t,
(*Client).CreateServer,
newResource,
"server",
"POST",
path.Join("servers"),
"{}",
)
assert.Equal(t, instance.ID, "srv-lv426")
}
func TestUpdateServer(t *testing.T) {
updatedResource := ServerOptions{ID: "srv-lv426"}
instance := testModify(
t,
(*Client).UpdateServer,
updatedResource,
"server",
"PUT",
path.Join("servers", updatedResource.ID),
"{}",
)
assert.Equal(t, instance.ID, updatedResource.ID)
}
func TestDestroyServer(t *testing.T) {
deletedResource := testModify(
t,
(*Client).DestroyServer,
"srv-lv426",
"server",
"DELETE",
path.Join("servers", "srv-lv426"),
"",
)
assert.Equal(t, deletedResource.ID, "srv-lv426")
}
func TestLockServer(t *testing.T) {
lockedResource := testModify(
t,
(*Client).LockServer,
"srv-lv426",
"server",
"PUT",
path.Join("servers", "srv-lv426", "lock_resource"),
"",
)
assert.Equal(t, lockedResource.ID, "srv-lv426")
}
func TestUnlockServer(t *testing.T) {
unlockedResource := testModify(
t,
(*Client).UnlockServer,
"srv-lv426",
"server",
"PUT",
path.Join("servers", "srv-lv426", "unlock_resource"),
"",
)
assert.Equal(t, unlockedResource.ID, "srv-lv426")
}
func TestServerCreatedAtUnix(t *testing.T) {
tm := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
target := Server{CreatedAt: &tm}
assert.Equal(t, target.CreatedAtUnix(), tm.Unix())
}
func TestResizeServer(t *testing.T) {
instance := testLink(
t,
(*Client).ResizeServer,
"srv-lv426",
ServerNewSize{"typ-12345"},
"server",
"POST",
path.Join("servers", "srv-lv426", "resize"),
`{"new_type":"typ-12345"}`,
)
assert.Equal(t, instance.ID, "srv-lv426")
}