@@ -689,7 +689,7 @@ func TestCheckDesiredState(t *testing.T) {
689
689
},
690
690
},
691
691
}, nil )
692
- _ , err := cloudInstance .checkDesiredState (context . Background (), tc .volumeID , tc .desiredSizeGiB , tc .options )
692
+ _ , err := cloudInstance .checkDesiredState (t . Context (), tc .volumeID , tc .desiredSizeGiB , tc .options )
693
693
if err != nil {
694
694
if tc .expErr == nil {
695
695
t .Fatalf ("Did not expect to get an error but got %q" , err )
@@ -1385,7 +1385,7 @@ func TestCreateDisk(t *testing.T) {
1385
1385
VolumeId : aws .String ("snap-test-volume" ),
1386
1386
State : types .SnapshotStateCompleted ,
1387
1387
}
1388
- ctx , ctxCancel := context .WithDeadline (context . Background (), time .Now ().Add (defaultCreateDiskDeadline ))
1388
+ ctx , ctxCancel := context .WithDeadline (t . Context (), time .Now ().Add (defaultCreateDiskDeadline ))
1389
1389
defer ctxCancel ()
1390
1390
1391
1391
if tc .expCreateVolumeInput != nil {
@@ -1506,7 +1506,7 @@ func TestCreateDiskClientToken(t *testing.T) {
1506
1506
}, nil ).AnyTimes (),
1507
1507
)
1508
1508
1509
- ctx , cancel := context .WithDeadline (context . Background (), time .Now ().Add (defaultCreateDiskDeadline ))
1509
+ ctx , cancel := context .WithDeadline (t . Context (), time .Now ().Add (defaultCreateDiskDeadline ))
1510
1510
defer cancel ()
1511
1511
for i := range 3 {
1512
1512
_ , err := c .CreateDisk (ctx , volumeName , diskOptions )
@@ -1551,7 +1551,7 @@ func TestDeleteDisk(t *testing.T) {
1551
1551
mockEC2 := NewMockEC2API (mockCtrl )
1552
1552
c := newCloud (mockEC2 )
1553
1553
1554
- ctx := context . Background ()
1554
+ ctx := t . Context ()
1555
1555
mockEC2 .EXPECT ().DeleteVolume (gomock .Any (), gomock .Any (), gomock .Any ()).Return (& ec2.DeleteVolumeOutput {}, tc .expErr )
1556
1556
1557
1557
ok , err := c .DeleteDisk (ctx , tc .volumeID )
@@ -1759,7 +1759,7 @@ func TestAttachDisk(t *testing.T) {
1759
1759
t .Fatalf ("could not assert c as type cloud, %v" , c )
1760
1760
}
1761
1761
1762
- ctx := context . Background ()
1762
+ ctx := t . Context ()
1763
1763
deviceManager := cloudInstance .dm
1764
1764
1765
1765
tc .mockFunc (mockEC2 , ctx , tc .volumeID , tc .nodeID , tc .nodeID2 , tc .path , deviceManager )
@@ -1848,7 +1848,7 @@ func TestDetachDisk(t *testing.T) {
1848
1848
mockEC2 := NewMockEC2API (mockCtrl )
1849
1849
c := newCloud (mockEC2 )
1850
1850
1851
- ctx := context . Background ()
1851
+ ctx := t . Context ()
1852
1852
tc .mockFunc (mockEC2 , ctx , tc .volumeID , tc .nodeID )
1853
1853
1854
1854
err := c .DetachDisk (ctx , tc .volumeID , tc .nodeID )
@@ -1916,7 +1916,7 @@ func TestGetDiskByName(t *testing.T) {
1916
1916
},
1917
1917
}
1918
1918
1919
- ctx := context . Background ()
1919
+ ctx := t . Context ()
1920
1920
mockEC2 .EXPECT ().DescribeVolumes (gomock .Any (), gomock .Any ()).Return (& ec2.DescribeVolumesOutput {Volumes : []types.Volume {vol }}, tc .expErr )
1921
1921
1922
1922
disk , err := c .GetDiskByName (ctx , tc .volumeName , tc .volumeCapacity )
@@ -2010,7 +2010,7 @@ func TestGetDiskByID(t *testing.T) {
2010
2010
mockEC2 := NewMockEC2API (mockCtrl )
2011
2011
c := newCloud (mockEC2 )
2012
2012
2013
- ctx := context . Background ()
2013
+ ctx := t . Context ()
2014
2014
2015
2015
mockEC2 .EXPECT ().DescribeVolumes (gomock .Any (), gomock .Any ()).Return (
2016
2016
& ec2.DescribeVolumesOutput {
@@ -2110,7 +2110,7 @@ func TestCreateSnapshot(t *testing.T) {
2110
2110
mockEC2 := NewMockEC2API (mockCtrl )
2111
2111
c := newCloud (mockEC2 )
2112
2112
2113
- ctx := context . Background ()
2113
+ ctx := t . Context ()
2114
2114
2115
2115
mockEC2 .EXPECT ().CreateSnapshot (gomock .Any (), gomock .Any (), gomock .Any ()).DoAndReturn (
2116
2116
func (ctx context.Context , input * ec2.CreateSnapshotInput , optFns ... func (* ec2.Options )) (* ec2.CreateSnapshotOutput , error ) {
@@ -2227,7 +2227,7 @@ func TestEnableFastSnapshotRestores(t *testing.T) {
2227
2227
mockEC2 := NewMockEC2API (mockCtrl )
2228
2228
c := newCloud (mockEC2 )
2229
2229
2230
- ctx := context . Background ()
2230
+ ctx := t . Context ()
2231
2231
mockEC2 .EXPECT ().EnableFastSnapshotRestores (gomock .Any (), gomock .Any (), gomock .Any ()).Return (tc .expOutput , tc .expErr ).AnyTimes ()
2232
2232
2233
2233
response , err := c .EnableFastSnapshotRestores (ctx , tc .availabilityZones , tc .snapshotID )
@@ -2290,7 +2290,7 @@ func TestAvailabilityZones(t *testing.T) {
2290
2290
mockEC2 := NewMockEC2API (mockCtrl )
2291
2291
c := newCloud (mockEC2 )
2292
2292
2293
- ctx := context . Background ()
2293
+ ctx := t . Context ()
2294
2294
mockEC2 .EXPECT ().DescribeAvailabilityZones (gomock .Any (), gomock .Any ()).Return (tc .expOutput , tc .expErr ).AnyTimes ()
2295
2295
2296
2296
az , err := c .AvailabilityZones (ctx )
@@ -2344,7 +2344,7 @@ func TestDeleteSnapshot(t *testing.T) {
2344
2344
mockEC2 := NewMockEC2API (mockCtrl )
2345
2345
c := newCloud (mockEC2 )
2346
2346
2347
- ctx := context . Background ()
2347
+ ctx := t . Context ()
2348
2348
mockEC2 .EXPECT ().DeleteSnapshot (gomock .Any (), gomock .Any (), gomock .Any ()).Return (& ec2.DeleteSnapshotOutput {}, tc .expErr )
2349
2349
2350
2350
_ , err := c .DeleteSnapshot (ctx , tc .snapshotName )
@@ -2633,7 +2633,7 @@ func TestResizeOrModifyDisk(t *testing.T) {
2633
2633
mockEC2 := NewMockEC2API (mockCtrl )
2634
2634
c := newCloud (mockEC2 )
2635
2635
2636
- ctx := context . Background ()
2636
+ ctx := t . Context ()
2637
2637
if tc .existingVolume != nil || tc .existingVolumeError != nil {
2638
2638
mockEC2 .EXPECT ().DescribeVolumes (gomock .Any (), gomock .Any ()).Return (
2639
2639
& ec2.DescribeVolumesOutput {
@@ -2767,7 +2767,7 @@ func TestModifyTags(t *testing.T) {
2767
2767
mockEC2 := NewMockEC2API (mockCtrl )
2768
2768
c := newCloud (mockEC2 )
2769
2769
2770
- ctx := context . Background ()
2770
+ ctx := t . Context ()
2771
2771
2772
2772
if len (tc .modifyTagsOptions .TagsToAdd ) > 0 {
2773
2773
if tc .negativeCase {
@@ -2857,7 +2857,7 @@ func TestGetSnapshotByName(t *testing.T) {
2857
2857
},
2858
2858
}
2859
2859
2860
- ctx := context . Background ()
2860
+ ctx := t . Context ()
2861
2861
2862
2862
mockEC2 .EXPECT ().DescribeSnapshots (gomock .Any (), gomock .Any ()).Return (& ec2.DescribeSnapshotsOutput {Snapshots : []types.Snapshot {ec2snapshot }}, nil )
2863
2863
@@ -2930,7 +2930,7 @@ func TestGetSnapshotByID(t *testing.T) {
2930
2930
State : types .SnapshotStateCompleted ,
2931
2931
}
2932
2932
2933
- ctx := context . Background ()
2933
+ ctx := t . Context ()
2934
2934
2935
2935
mockEC2 .EXPECT ().DescribeSnapshots (gomock .Any (), gomock .Any ()).Return (& ec2.DescribeSnapshotsOutput {Snapshots : []types.Snapshot {ec2snapshot }}, nil )
2936
2936
@@ -3014,7 +3014,7 @@ func TestListSnapshots(t *testing.T) {
3014
3014
mockEC2 := NewMockEC2API (mockCtl )
3015
3015
c := newCloud (mockEC2 )
3016
3016
3017
- ctx := context . Background ()
3017
+ ctx := t . Context ()
3018
3018
3019
3019
mockEC2 .EXPECT ().DescribeSnapshots (gomock .Any (), gomock .Any ()).Return (& ec2.DescribeSnapshotsOutput {Snapshots : ec2Snapshots }, nil )
3020
3020
@@ -3089,7 +3089,7 @@ func TestListSnapshots(t *testing.T) {
3089
3089
mockEC2 := NewMockEC2API (mockCtl )
3090
3090
c := newCloud (mockEC2 )
3091
3091
3092
- ctx := context . Background ()
3092
+ ctx := t . Context ()
3093
3093
3094
3094
mockEC2 .EXPECT ().DescribeSnapshots (gomock .Any (), gomock .Any ()).Return (& ec2.DescribeSnapshotsOutput {Snapshots : ec2Snapshots }, nil )
3095
3095
@@ -3153,7 +3153,7 @@ func TestListSnapshots(t *testing.T) {
3153
3153
mockEC2 := NewMockEC2API (mockCtl )
3154
3154
c := newCloud (mockEC2 )
3155
3155
3156
- ctx := context . Background ()
3156
+ ctx := t . Context ()
3157
3157
3158
3158
firstCall := mockEC2 .EXPECT ().DescribeSnapshots (gomock .Any (), gomock .Any ()).Return (& ec2.DescribeSnapshotsOutput {
3159
3159
Snapshots : ec2Snapshots [:maxResults ],
@@ -3203,7 +3203,7 @@ func TestListSnapshots(t *testing.T) {
3203
3203
mockEC2 := NewMockEC2API (mockCtl )
3204
3204
c := newCloud (mockEC2 )
3205
3205
3206
- ctx := context . Background ()
3206
+ ctx := t . Context ()
3207
3207
3208
3208
mockEC2 .EXPECT ().DescribeSnapshots (gomock .Any (), gomock .Any ()).Return (nil , errors .New ("test error" ))
3209
3209
@@ -3221,7 +3221,7 @@ func TestListSnapshots(t *testing.T) {
3221
3221
mockEC2 := NewMockEC2API (mockCtl )
3222
3222
c := newCloud (mockEC2 )
3223
3223
3224
- ctx := context . Background ()
3224
+ ctx := t . Context ()
3225
3225
3226
3226
mockEC2 .EXPECT ().DescribeSnapshots (gomock .Any (), gomock .Any ()).Return (& ec2.DescribeSnapshotsOutput {}, nil )
3227
3227
@@ -3371,7 +3371,7 @@ func TestWaitForAttachmentState(t *testing.T) {
3371
3371
MultiAttachEnabled : aws .Bool (false ),
3372
3372
}
3373
3373
3374
- ctx , cancel := context .WithCancel (context . Background ())
3374
+ ctx , cancel := context .WithCancel (t . Context ())
3375
3375
defer cancel ()
3376
3376
3377
3377
switch tc .name {
0 commit comments