@@ -634,6 +634,7 @@ type provisioningTestcase struct {
634634 getSecretRefErr bool
635635 getCredentialsErr bool
636636 volWithLessCap bool
637+ volWithZeroCap bool
637638 expectedPVSpec * pvSpec
638639 withSecretRefs bool
639640 expectErr bool
@@ -1093,6 +1094,32 @@ func TestProvision(t *testing.T) {
10931094 }
10941095 },
10951096 },
1097+ "provision with size 0" : {
1098+ volOpts : controller.VolumeOptions {
1099+ PersistentVolumeReclaimPolicy : v1 .PersistentVolumeReclaimDelete ,
1100+ PVName : "test-name" ,
1101+ PVC : createFakePVC (requestedBytes ),
1102+ Parameters : map [string ]string {
1103+ "fstype" : "ext3" ,
1104+ },
1105+ },
1106+ volWithZeroCap : true ,
1107+ expectedPVSpec : & pvSpec {
1108+ Name : "test-testi" ,
1109+ ReclaimPolicy : v1 .PersistentVolumeReclaimDelete ,
1110+ Capacity : v1.ResourceList {
1111+ v1 .ResourceName (v1 .ResourceStorage ): bytesToGiQuantity (requestedBytes ),
1112+ },
1113+ CSIPVS : & v1.CSIPersistentVolumeSource {
1114+ Driver : "test-driver" ,
1115+ VolumeHandle : "test-volume-id" ,
1116+ FSType : "ext3" ,
1117+ VolumeAttributes : map [string ]string {
1118+ "storage.kubernetes.io/csiProvisionerIdentity" : "test-provisioner" ,
1119+ },
1120+ },
1121+ },
1122+ },
10961123 }
10971124
10981125 for k , tc := range testcases {
@@ -1196,6 +1223,9 @@ func runProvisionTest(t *testing.T, k string, tc provisioningTestcase, requested
11961223 out .Volume .CapacityBytes = int64 (80 )
11971224 controllerServer .EXPECT ().CreateVolume (gomock .Any (), gomock .Any ()).Return (out , nil ).Times (1 )
11981225 controllerServer .EXPECT ().DeleteVolume (gomock .Any (), gomock .Any ()).Return (& csi.DeleteVolumeResponse {}, nil ).Times (1 )
1226+ } else if tc .volWithZeroCap {
1227+ out .Volume .CapacityBytes = int64 (0 )
1228+ controllerServer .EXPECT ().CreateVolume (gomock .Any (), gomock .Any ()).Return (out , nil ).Times (1 )
11991229 } else if tc .expectCreateVolDo != nil {
12001230 controllerServer .EXPECT ().CreateVolume (gomock .Any (), gomock .Any ()).Do (tc .expectCreateVolDo ).Return (out , nil ).Times (1 )
12011231 } else {
0 commit comments