@@ -372,6 +372,13 @@ func TestControllerGetCapabilities(t *testing.T) {
372
372
},
373
373
},
374
374
},
375
+ {
376
+ Type : & csi.ControllerServiceCapability_Rpc {
377
+ Rpc : & csi.ControllerServiceCapability_RPC {
378
+ Type : csi .ControllerServiceCapability_RPC_EXPAND_VOLUME ,
379
+ },
380
+ },
381
+ },
375
382
},
376
383
},
377
384
expectedErr : nil ,
@@ -1057,6 +1064,60 @@ func TestDeleteSnapshot(t *testing.T) {
1057
1064
}
1058
1065
}
1059
1066
1067
+ func TestControllerExpandVolume (t * testing.T ) {
1068
+ testCases := []struct {
1069
+ name string
1070
+ testFunc func (t * testing.T )
1071
+ }{
1072
+ {
1073
+ name : "volume ID missing" ,
1074
+ testFunc : func (t * testing.T ) {
1075
+ d := initTestController (t )
1076
+ req := & csi.ControllerExpandVolumeRequest {}
1077
+ _ , err := d .ControllerExpandVolume (context .Background (), req )
1078
+ expectedErr := status .Error (codes .InvalidArgument , "Volume ID missing in request" )
1079
+ if ! reflect .DeepEqual (err , expectedErr ) {
1080
+ t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , expectedErr )
1081
+ }
1082
+ },
1083
+ },
1084
+ {
1085
+ name : "Capacity Range missing" ,
1086
+ testFunc : func (t * testing.T ) {
1087
+ d := initTestController (t )
1088
+ req := & csi.ControllerExpandVolumeRequest {
1089
+ VolumeId : "unit-test" ,
1090
+ }
1091
+ _ , err := d .ControllerExpandVolume (context .Background (), req )
1092
+ expectedErr := status .Error (codes .InvalidArgument , "Capacity Range missing in request" )
1093
+ if ! reflect .DeepEqual (err , expectedErr ) {
1094
+ t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , expectedErr )
1095
+ }
1096
+ },
1097
+ },
1098
+ {
1099
+ name : "Error = nil" ,
1100
+ testFunc : func (t * testing.T ) {
1101
+ d := initTestController (t )
1102
+ req := & csi.ControllerExpandVolumeRequest {
1103
+ VolumeId : "unit-test" ,
1104
+ CapacityRange : & csi.CapacityRange {
1105
+ RequiredBytes : 10000 ,
1106
+ },
1107
+ }
1108
+ _ , err := d .ControllerExpandVolume (context .Background (), req )
1109
+ if ! reflect .DeepEqual (err , nil ) {
1110
+ t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , nil )
1111
+ }
1112
+ },
1113
+ },
1114
+ }
1115
+
1116
+ for _ , tc := range testCases {
1117
+ t .Run (tc .name , tc .testFunc )
1118
+ }
1119
+ }
1120
+
1060
1121
func matchCreateSnapshotResponse (e , r * csi.CreateSnapshotResponse ) error {
1061
1122
if e == nil && r == nil {
1062
1123
return nil
0 commit comments