Skip to content

Commit 54ec7bf

Browse files
committed
completed unit test TestControllerExpandVolume
1 parent d022df0 commit 54ec7bf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

pkg/blob/controllerserver_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,42 @@ func TestControllerExpandVolume(t *testing.T) {
730730
}
731731
},
732732
},
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+
},
733769
}
734770

735771
for _, tc := range testCases {

0 commit comments

Comments
 (0)