@@ -25,11 +25,12 @@ import (
25
25
26
26
func TestExtractAndDefaultParameters (t * testing.T ) {
27
27
tests := []struct {
28
- name string
29
- parameters map [string ]string
30
- labels map [string ]string
31
- expectParams DiskParameters
32
- expectErr bool
28
+ name string
29
+ parameters map [string ]string
30
+ labels map [string ]string
31
+ enableStoragePools bool
32
+ expectParams DiskParameters
33
+ expectErr bool
33
34
}{
34
35
{
35
36
name : "defaults" ,
@@ -202,9 +203,10 @@ func TestExtractAndDefaultParameters(t *testing.T) {
202
203
},
203
204
},
204
205
{
205
- name : "storage pool parameters" ,
206
- parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "projects/my-project/zones/us-central1-a/storagePools/storagePool-1,projects/my-project/zones/us-central1-b/storagePools/storagePool-2" },
207
- labels : map [string ]string {},
206
+ name : "storage pool parameters" ,
207
+ enableStoragePools : true ,
208
+ parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "projects/my-project/zones/us-central1-a/storagePools/storagePool-1,projects/my-project/zones/us-central1-b/storagePools/storagePool-2" },
209
+ labels : map [string ]string {},
208
210
expectParams : DiskParameters {
209
211
DiskType : "hyperdisk-balanced" ,
210
212
ReplicationType : "none" ,
@@ -227,46 +229,59 @@ func TestExtractAndDefaultParameters(t *testing.T) {
227
229
},
228
230
},
229
231
{
230
- name : "invalid storage pool parameters, starts with /projects instead of projects" ,
231
- parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "/projects/my-project/zones/us-central1-a/storagePools/storagePool-1" },
232
- labels : map [string ]string {},
233
- expectErr : true ,
232
+ name : "invalid storage pool parameters, starts with /projects instead of projects" ,
233
+ enableStoragePools : true ,
234
+ parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "/projects/my-project/zones/us-central1-a/storagePools/storagePool-1" },
235
+ labels : map [string ]string {},
236
+ expectErr : true ,
234
237
},
235
238
{
236
- name : "invalid storage pool parameters, missing projects" ,
237
- parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "zones/us-central1-a/storagePools/storagePool-1" },
238
- labels : map [string ]string {},
239
- expectErr : true ,
239
+ name : "invalid storage pool parameters, missing projects" ,
240
+ enableStoragePools : true ,
241
+ parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "zones/us-central1-a/storagePools/storagePool-1" },
242
+ labels : map [string ]string {},
243
+ expectErr : true ,
240
244
},
241
245
{
242
- name : "invalid storage pool parameters, missing zones" ,
243
- parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "projects/my-project/storagePools/storagePool-1" },
244
- labels : map [string ]string {},
245
- expectErr : true ,
246
+ name : "invalid storage pool parameters, missing zones" ,
247
+ enableStoragePools : true ,
248
+ parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "projects/my-project/storagePools/storagePool-1" },
249
+ labels : map [string ]string {},
250
+ expectErr : true ,
246
251
},
247
252
{
248
- name : "invalid storage pool parameters, duplicate projects" ,
249
- parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "projects/my-project/projects/my-project/storagePools/storagePool-1" },
250
- labels : map [string ]string {},
251
- expectErr : true ,
253
+ name : "invalid storage pool parameters, duplicate projects" ,
254
+ enableStoragePools : true ,
255
+ parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "projects/my-project/projects/my-project/storagePools/storagePool-1" },
256
+ labels : map [string ]string {},
257
+ expectErr : true ,
252
258
},
253
259
{
254
- name : "invalid storage pool parameters, duplicate zones" ,
255
- parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "zones/us-central1-a/zones/us-central1-a/storagePools/storagePool-1" },
256
- labels : map [string ]string {},
257
- expectErr : true ,
260
+ name : "invalid storage pool parameters, duplicate zones" ,
261
+ enableStoragePools : true ,
262
+ parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "zones/us-central1-a/zones/us-central1-a/storagePools/storagePool-1" },
263
+ labels : map [string ]string {},
264
+ expectErr : true ,
258
265
},
259
266
{
260
- name : "invalid storage pool parameters, duplicate storagePools" ,
261
- parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "projects/my-project/storagePools/us-central1-a/storagePools/storagePool-1" },
262
- labels : map [string ]string {},
263
- expectErr : true ,
267
+ name : "invalid storage pool parameters, duplicate storagePools" ,
268
+ enableStoragePools : true ,
269
+ parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "projects/my-project/storagePools/us-central1-a/storagePools/storagePool-1" },
270
+ labels : map [string ]string {},
271
+ expectErr : true ,
272
+ },
273
+ {
274
+ name : "storage pool parameters, enableStoragePools is false" ,
275
+ enableStoragePools : false ,
276
+ parameters : map [string ]string {ParameterKeyType : "hyperdisk-balanced" , ParameterKeyStoragePools : "projects/my-project/zones/us-central1-a/storagePools/storagePool-1,projects/my-project/zones/us-central1-b/storagePools/storagePool-2" },
277
+ labels : map [string ]string {},
278
+ expectErr : true ,
264
279
},
265
280
}
266
281
267
282
for _ , tc := range tests {
268
283
t .Run (tc .name , func (t * testing.T ) {
269
- p , err := ExtractAndDefaultParameters (tc .parameters , "testDriver" , tc .labels )
284
+ p , err := ExtractAndDefaultParameters (tc .parameters , "testDriver" , tc .labels , tc . enableStoragePools )
270
285
if gotErr := err != nil ; gotErr != tc .expectErr {
271
286
t .Fatalf ("ExtractAndDefaultParameters(%+v) = %v; expectedErr: %v" , tc .parameters , err , tc .expectErr )
272
287
}
0 commit comments