@@ -383,6 +383,49 @@ func TestSwapVolumeTransformer(t *testing.T) {
383383 assert .Equal (t , block .FilesystemTypeSwap , vc .TypedSpec ().Provisioning .FilesystemSpec .Type )
384384 assert .Equal (t , constants .SwapVolumePrefix + "swap1" , vc .TypedSpec ().Provisioning .PartitionSpec .Label )
385385 assert .Equal (t , block .WaveUserVolumes , vc .TypedSpec ().Provisioning .Wave )
386+
387+ assert .EqualValues (t , volumeconfig .MinUserVolumeSize , vc .TypedSpec ().Provisioning .PartitionSpec .MinSize )
388+ assert .EqualValues (t , 0 , vc .TypedSpec ().Provisioning .PartitionSpec .MaxSize )
389+ })
390+
391+ testMountTransformFunc (t , resources [0 ].MountTransformFunc , func (t * testing.T , m * block.VolumeMountRequest , err error ) {
392+ // default mount transform is noop
393+ require .NoError (t , err )
394+ })
395+ },
396+ },
397+ {
398+ name : "swap volume with sizes" ,
399+ cfg : []* blockcfg.SwapVolumeConfigV1Alpha1 {
400+ {
401+ Meta : meta.Meta {
402+ MetaKind : blockcfg .SwapVolumeConfigKind ,
403+ MetaAPIVersion : "v1alpha1" ,
404+ },
405+ MetaName : "swap1" ,
406+ ProvisioningSpec : blockcfg.ProvisioningSpec {
407+ ProvisioningMinSize : blockcfg .MustByteSize ("1GB" ),
408+ ProvisioningMaxSize : blockcfg .MustSize ("2GB" ),
409+ },
410+ },
411+ },
412+ checkFunc : func (t * testing.T , resources []volumeconfig.VolumeResource ) {
413+ require .Len (t , resources , 1 )
414+
415+ assert .Equal (t , constants .SwapVolumePrefix + "swap1" , resources [0 ].VolumeID )
416+ assert .Equal (t , block .SwapVolumeLabel , resources [0 ].Label )
417+
418+ testTransformFunc (t , resources [0 ].TransformFunc , func (t * testing.T , vc * block.VolumeConfig , err error ) {
419+ require .NoError (t , err )
420+
421+ assert .Equal (t , block .VolumeTypePartition , vc .TypedSpec ().Type )
422+
423+ assert .Equal (t , block .FilesystemTypeSwap , vc .TypedSpec ().Provisioning .FilesystemSpec .Type )
424+ assert .Equal (t , constants .SwapVolumePrefix + "swap1" , vc .TypedSpec ().Provisioning .PartitionSpec .Label )
425+ assert .Equal (t , block .WaveUserVolumes , vc .TypedSpec ().Provisioning .Wave )
426+
427+ assert .EqualValues (t , 1 * 1000 * 1000 * 1000 , vc .TypedSpec ().Provisioning .PartitionSpec .MinSize )
428+ assert .EqualValues (t , 2 * 1000 * 1000 * 1000 , vc .TypedSpec ().Provisioning .PartitionSpec .MaxSize )
386429 })
387430
388431 testMountTransformFunc (t , resources [0 ].MountTransformFunc , func (t * testing.T , m * block.VolumeMountRequest , err error ) {
0 commit comments