/
fixtures.go
201 lines (187 loc) · 4.9 KB
/
fixtures.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
package testing
import (
"time"
"github.com/selectel/go-selvpcclient/v3/selvpcclient"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/servers"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/subnets"
)
// TestGetSubnetResponseRaw represents a raw response from the Get request.
const TestGetSubnetResponseRaw = `
{
"subnet": {
"cidr": "203.0.113.0/24",
"id": 111122,
"network_id": "8233f12e-c47e-4f1c-953a-1ecd322a7119",
"project_id": "49338ac045f448e294b25d013f890317",
"region": "ru-3",
"servers": [
{
"id": "253b680c-89f6-4c85-afbf-c9a67c92d3fe",
"name": "Node01",
"status": "ACTIVE",
"updated": "2018-03-12T14:56:19Z"
}
],
"status": "ACTIVE",
"subnet_id": "94425a6e-19cd-412d-9710-ff40b34a78f4"
}
}
`
var subnetServerTimeStamp, _ = time.Parse(time.RFC3339, "2018-03-12T14:56:19Z")
// TestGetSubnetResponse represents an unmarshalled TestGetSubnetResponseRaw.
var TestGetSubnetResponse = &subnets.Subnet{
ID: 111122,
Status: "ACTIVE",
Servers: []servers.Server{
{
ID: "253b680c-89f6-4c85-afbf-c9a67c92d3fe",
Name: "Node01",
Status: "ACTIVE",
Updated: subnetServerTimeStamp,
},
},
Region: "ru-3",
CIDR: "203.0.113.0/24",
NetworkID: "8233f12e-c47e-4f1c-953a-1ecd322a7119",
SubnetID: "94425a6e-19cd-412d-9710-ff40b34a78f4",
ProjectID: "49338ac045f448e294b25d013f890317",
}
// TestListSubnetsResponseRaw represents a raw response from the List request.
const TestListSubnetsResponseRaw = `
{
"subnets": [
{
"cidr": "203.0.113.0/24",
"id": 112233,
"project_id": "49338ac045f448e294b25d013f890317",
"region": "ru-3",
"status": "ACTIVE"
},
{
"cidr": "198.51.100.0/24",
"id": 112234,
"project_id": "9c97bdc75295493096cf5edcb8c37933",
"region": "ru-2",
"status": "ACTIVE"
}
]
}
`
// TestListSubnetsSingleResponseRaw represents a raw response with a single subnet from the List request.
const TestListSubnetsSingleResponseRaw = `
{
"subnets": [
{
"cidr": "203.0.113.0/24",
"id": 112233,
"project_id": "49338ac045f448e294b25d013f890317",
"region": "ru-3",
"status": "ACTIVE"
}
]
}
`
// TestListSubnetsSingleResponse represents the unmarshalled TestListSubnetsSingleResponseRaw response.
var TestListSubnetsSingleResponse = []*subnets.Subnet{
{
CIDR: "203.0.113.0/24",
ID: 112233,
ProjectID: "49338ac045f448e294b25d013f890317",
Region: "ru-3",
Status: "ACTIVE",
},
}
// TestCreateSubnetsOptsRaw represents marshalled options for the Create request.
const TestCreateSubnetsOptsRaw = `
{
"subnets": [
{
"region": "ru-2",
"type": "ipv4",
"quantity": 1,
"prefix_length": 29
},
{
"region": "ru-1",
"type": "ipv4",
"quantity": 1,
"prefix_length": 29
}
]
}
`
// TestCreateSubnetsOpts represent options for the Create request.
var TestCreateSubnetsOpts = subnets.SubnetOpts{
Subnets: []subnets.SubnetOpt{
{
Region: "ru-2",
Quantity: 1,
Type: selvpcclient.IPv4,
PrefixLength: 29,
},
{
Region: "ru-1",
Quantity: 1,
Type: selvpcclient.IPv4,
PrefixLength: 29,
},
},
}
// TestCreateSubnetsResponseRaw represents a raw response from the Create request.
const TestCreateSubnetsResponseRaw = `
{
"subnets": [
{
"cidr": "203.0.113.0/29",
"id": 112233,
"project_id": "9c97bdc75295493096cf5edcb8c37933",
"region": "ru-2",
"status": "DOWN"
},
{
"cidr": "198.51.100.0/29",
"id": 112234,
"project_id": "9c97bdc75295493096cf5edcb8c37933",
"region": "ru-1",
"status": "DOWN"
}
]
}
`
// TestCreateSubnetResponse represents the unmarshalled TestCreateSubnetsResponseRaw response.
var TestCreateSubnetResponse = []*subnets.Subnet{
{
CIDR: "203.0.113.0/29",
ID: 112233,
ProjectID: "9c97bdc75295493096cf5edcb8c37933",
Region: "ru-2",
Status: "DOWN",
},
{
CIDR: "198.51.100.0/29",
ID: 112234,
ProjectID: "9c97bdc75295493096cf5edcb8c37933",
Region: "ru-1",
Status: "DOWN",
},
}
// TestManySubnetsInvalidResponseRaw represents a raw invalid response with several subnets.
const TestManySubnetsInvalidResponseRaw = `
{
"subnets": [
{
"id": "222"
}
]
}
`
// TestSingleSubnetInvalidResponseRaw represents a raw invalid response with a single subnet.
const TestSingleSubnetInvalidResponseRaw = `
{
"subnet": [
{
"id": "222"
}
]
}
`