@@ -398,11 +398,54 @@ func TestListVolumes(t *testing.T) {
398398
399399func TestControllerExpandVolume (t * testing.T ) {
400400 d := NewFakeDriver ()
401- req := csi.ControllerExpandVolumeRequest {}
402- resp , err := d .ControllerExpandVolume (context .Background (), & req )
403- assert .Nil (t , resp )
404- if ! reflect .DeepEqual (err , status .Error (codes .Unimplemented , "" )) {
405- t .Errorf ("Unexpected error: %v" , err )
401+
402+ testCases := []struct {
403+ name string
404+ testFunc func (t * testing.T )
405+ }{
406+ {
407+ name : "volume ID missing" ,
408+ testFunc : func (t * testing.T ) {
409+ req := & csi.ControllerExpandVolumeRequest {}
410+ _ , err := d .ControllerExpandVolume (context .Background (), req )
411+ expectedErr := status .Error (codes .InvalidArgument , "Volume ID missing in request" )
412+ if ! reflect .DeepEqual (err , expectedErr ) {
413+ t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , expectedErr )
414+ }
415+ },
416+ },
417+ {
418+ name : "Capacity Range missing" ,
419+ testFunc : func (t * testing.T ) {
420+ req := & csi.ControllerExpandVolumeRequest {
421+ VolumeId : "unit-test" ,
422+ }
423+ _ , err := d .ControllerExpandVolume (context .Background (), req )
424+ expectedErr := status .Error (codes .InvalidArgument , "Capacity Range missing in request" )
425+ if ! reflect .DeepEqual (err , expectedErr ) {
426+ t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , expectedErr )
427+ }
428+ },
429+ },
430+ {
431+ name : "Error = nil" ,
432+ testFunc : func (t * testing.T ) {
433+ req := & csi.ControllerExpandVolumeRequest {
434+ VolumeId : "unit-test" ,
435+ CapacityRange : & csi.CapacityRange {
436+ RequiredBytes : 10000 ,
437+ },
438+ }
439+ _ , err := d .ControllerExpandVolume (context .Background (), req )
440+ if ! reflect .DeepEqual (err , nil ) {
441+ t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , nil )
442+ }
443+ },
444+ },
445+ }
446+
447+ for _ , tc := range testCases {
448+ t .Run (tc .name , tc .testFunc )
406449 }
407450}
408451
0 commit comments