@@ -730,6 +730,42 @@ func TestControllerExpandVolume(t *testing.T) {
730
730
}
731
731
},
732
732
},
733
+ {
734
+ name : "Volume Size exceeds Max Container Size" ,
735
+ testFunc : func (t * testing.T ) {
736
+ d := NewFakeDriver ()
737
+ d .AddControllerServiceCapabilities ([]csi.ControllerServiceCapability_RPC_Type {csi .ControllerServiceCapability_RPC_EXPAND_VOLUME })
738
+ req := & csi.ControllerExpandVolumeRequest {
739
+ VolumeId : "unit-test" ,
740
+ CapacityRange : & csi.CapacityRange {
741
+ RequiredBytes : containerMaxSize + 1 ,
742
+ },
743
+ }
744
+ _ , err := d .ControllerExpandVolume (context .Background (), req )
745
+ expectedErr := status .Errorf (codes .OutOfRange , "required bytes (%d) exceeds the maximum supported bytes (%d)" , req .CapacityRange .RequiredBytes , containerMaxSize )
746
+ if ! reflect .DeepEqual (err , expectedErr ) {
747
+ t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , expectedErr )
748
+ }
749
+ },
750
+ },
751
+ {
752
+ name : "Error = nil" ,
753
+ testFunc : func (t * testing.T ) {
754
+ d := NewFakeDriver ()
755
+ d .AddControllerServiceCapabilities ([]csi.ControllerServiceCapability_RPC_Type {csi .ControllerServiceCapability_RPC_EXPAND_VOLUME })
756
+ req := & csi.ControllerExpandVolumeRequest {
757
+ VolumeId : "unit-test" ,
758
+ CapacityRange : & csi.CapacityRange {
759
+ RequiredBytes : containerMaxSize ,
760
+ },
761
+ }
762
+ _ , err := d .ControllerExpandVolume (context .Background (), req )
763
+ var expectedErr error = nil
764
+ if ! reflect .DeepEqual (err , expectedErr ) {
765
+ t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , expectedErr )
766
+ }
767
+ },
768
+ },
733
769
}
734
770
735
771
for _ , tc := range testCases {
0 commit comments