@@ -305,17 +305,23 @@ var _ = Describe("ControllerServer test", Ordered, func() {
305305 Id : new ("snapshot - volume - id "),
306306 AvailabilityZone : "eu01" ,
307307 }, nil )
308- iaasClient .EXPECT ().CreateVolume (gomock .Any (), gomock .Any ()).
309- Do (func (_ context.Context , opts * iaas.CreateVolumePayload ) {
308+ iaasClient .EXPECT ().
309+ CreateVolume (gomock .Any (), gomock .Any ()).
310+ DoAndReturn (func (_ context.Context , opts * iaas.CreateVolumePayload ) (* iaas.Volume , error ) {
310311 Expect (opts .Source .Id ).To (Equal ("snapshot-id" ))
311312 Expect (opts .Source .Type ).To (Equal ("snapshot" ))
312- }).
313- Return (& iaas.Volume {
314- Id : new ("volume - id "),
315- Name : new ("new volume "),
316- AvailabilityZone : "eu01" ,
317- Size : new (int64 (20 )),
318- }, nil )
313+
314+ volumeID := "volume-id"
315+ name := "new volume"
316+ size := int64 (20 )
317+
318+ return & iaas.Volume {
319+ Id : & volumeID ,
320+ Name : & name ,
321+ AvailabilityZone : "eu01" ,
322+ Size : & size ,
323+ }, nil
324+ })
319325 iaasClient .EXPECT ().WaitVolumeTargetStatusWithCustomBackoff (gomock .Any (), "volume-id" , gomock .Any (), gomock .Any ()).Return (nil )
320326
321327 _ , err := fakeCs .CreateVolume (context .Background (), req )
@@ -375,17 +381,23 @@ var _ = Describe("ControllerServer test", Ordered, func() {
375381 Status : new ("AVAILABLE "),
376382 AvailabilityZone : new ("eu01 "),
377383 }, nil )
378- iaasClient .EXPECT ().CreateVolume (gomock .Any (), gomock .Any ()).
379- Do (func (_ context.Context , opts * iaas.CreateVolumePayload ) {
384+ iaasClient .EXPECT ().
385+ CreateVolume (gomock .Any (), gomock .Any ()).
386+ DoAndReturn (func (_ context.Context , opts * iaas.CreateVolumePayload ) (* iaas.Volume , error ) {
380387 Expect (opts .Source .Id ).To (Equal ("snapshot-id" ))
381388 Expect (opts .Source .Type ).To (Equal ("backup" ))
382- }).
383- Return (& iaas.Volume {
384- Id : new ("volume - id "),
385- Name : new ("new volume "),
386- AvailabilityZone : "eu01" ,
387- Size : new (int64 (20 )),
388- }, nil )
389+
390+ volumeID := "volume-id"
391+ name := "new volume"
392+ size := int64 (20 )
393+
394+ return & iaas.Volume {
395+ Id : & volumeID ,
396+ Name : & name ,
397+ AvailabilityZone : "eu01" ,
398+ Size : & size ,
399+ }, nil
400+ })
389401 iaasClient .EXPECT ().WaitVolumeTargetStatusWithCustomBackoff (gomock .Any (), "volume-id" , gomock .Any (), gomock .Any ()).Return (nil )
390402
391403 _ , err := fakeCs .CreateVolume (context .Background (), req )
@@ -484,17 +496,23 @@ var _ = Describe("ControllerServer test", Ordered, func() {
484496 Status : new ("AVAILABLE "),
485497 AvailabilityZone : "eu01" ,
486498 }, nil )
487- iaasClient .EXPECT ().CreateVolume (gomock .Any (), gomock .Any ()).
488- Do (func (_ context.Context , opts * iaas.CreateVolumePayload ) {
499+ iaasClient .EXPECT ().
500+ CreateVolume (gomock .Any (), gomock .Any ()).
501+ DoAndReturn (func (_ context.Context , opts * iaas.CreateVolumePayload ) (* iaas.Volume , error ) {
489502 Expect (opts .Source .Id ).To (Equal ("volume-source-id" ))
490503 Expect (opts .Source .Type ).To (Equal ("volume" ))
491- }).
492- Return (& iaas.Volume {
493- Id : new ("volume - id "),
494- Name : new ("new volume "),
495- AvailabilityZone : "eu01" ,
496- Size : new (int64 (20 )),
497- }, nil )
504+
505+ name := "new volume"
506+ volumeID := "volume-id"
507+ size := int64 (20 )
508+
509+ return & iaas.Volume {
510+ Id : & volumeID ,
511+ Name : & name ,
512+ AvailabilityZone : "eu01" ,
513+ Size : & size ,
514+ }, nil
515+ })
498516 iaasClient .EXPECT ().WaitVolumeTargetStatusWithCustomBackoff (gomock .Any (), "volume-id" , gomock .Any (), gomock .Any ()).Return (nil )
499517
500518 _ , err := fakeCs .CreateVolume (context .Background (), req )
0 commit comments