@@ -263,16 +263,14 @@ func TestDevfile200_DeleteVolumeMounts(t *testing.T) {
263
263
264
264
}
265
265
266
- func TestDevfile200_GetVolumeMountPath (t * testing.T ) {
267
- volume1 := "volume1"
268
- component1 := "component1"
266
+ func TestDevfile200_GetVolumeMountPaths (t * testing.T ) {
269
267
270
268
tests := []struct {
271
269
name string
272
270
currentComponents []v1.Component
273
271
mountName string
274
272
componentName string
275
- wantPath string
273
+ wantPaths [] string
276
274
wantErr bool
277
275
}{
278
276
{
@@ -283,17 +281,18 @@ func TestDevfile200_GetVolumeMountPath(t *testing.T) {
283
281
Container : & v1.ContainerComponent {
284
282
Container : v1.Container {
285
283
VolumeMounts : []v1.VolumeMount {
286
- testingutil .GetFakeVolumeMount (volume1 , "/path" ),
284
+ testingutil .GetFakeVolumeMount ("volume1" , "/path" ),
285
+ testingutil .GetFakeVolumeMount ("volume1" , "/path2" ),
287
286
},
288
287
},
289
288
},
290
289
},
291
- Name : component1 ,
290
+ Name : " component1" ,
292
291
},
293
292
},
294
- wantPath : "/path" ,
295
- mountName : volume1 ,
296
- componentName : component1 ,
293
+ wantPaths : [] string { "/path" , "/path2" } ,
294
+ mountName : " volume1" ,
295
+ componentName : " component1" ,
297
296
wantErr : false ,
298
297
},
299
298
{
@@ -304,16 +303,16 @@ func TestDevfile200_GetVolumeMountPath(t *testing.T) {
304
303
Container : & v1.ContainerComponent {
305
304
Container : v1.Container {
306
305
VolumeMounts : []v1.VolumeMount {
307
- testingutil .GetFakeVolumeMount (volume1 , "/path" ),
306
+ testingutil .GetFakeVolumeMount (" volume1" , "/path" ),
308
307
},
309
308
},
310
309
},
311
310
},
312
- Name : component1 ,
311
+ Name : " component1" ,
313
312
},
314
313
},
315
314
mountName : "volume2" ,
316
- componentName : component1 ,
315
+ componentName : " component1" ,
317
316
wantErr : true ,
318
317
},
319
318
{
@@ -324,15 +323,15 @@ func TestDevfile200_GetVolumeMountPath(t *testing.T) {
324
323
Container : & v1.ContainerComponent {
325
324
Container : v1.Container {
326
325
VolumeMounts : []v1.VolumeMount {
327
- testingutil .GetFakeVolumeMount (volume1 , "/path" ),
326
+ testingutil .GetFakeVolumeMount (" volume1" , "/path" ),
328
327
},
329
328
},
330
329
},
331
330
},
332
- Name : component1 ,
331
+ Name : " component1" ,
333
332
},
334
333
},
335
- mountName : volume1 ,
334
+ mountName : " volume1" ,
336
335
componentName : "component2" ,
337
336
wantErr : true ,
338
337
},
@@ -348,11 +347,26 @@ func TestDevfile200_GetVolumeMountPath(t *testing.T) {
348
347
},
349
348
},
350
349
}
351
- gotPath , err := d .GetVolumeMountPath (tt .mountName , tt .componentName )
350
+ gotPaths , err := d .GetVolumeMountPaths (tt .mountName , tt .componentName )
352
351
if (err != nil ) != tt .wantErr {
353
352
t .Errorf ("GetVolumeMountPath() error = %v, wantErr %v" , err , tt .wantErr )
354
353
} else if err == nil {
355
- assert .Equal (t , tt .wantPath , gotPath , "The two values should be the same." )
354
+ if len (gotPaths ) != len (tt .wantPaths ) {
355
+ t .Error ("expected mount paths length not the same as actual mount paths length" )
356
+ }
357
+
358
+ for _ , wantPath := range tt .wantPaths {
359
+ matched := false
360
+ for _ , gotPath := range gotPaths {
361
+ if wantPath == gotPath {
362
+ matched = true
363
+ }
364
+ }
365
+
366
+ if ! matched {
367
+ t .Errorf ("unable to find the wanted mount path %s in the actual mount paths slice" , wantPath )
368
+ }
369
+ }
356
370
}
357
371
})
358
372
}
0 commit comments