@@ -17,7 +17,6 @@ limitations under the License.
1717package controllers
1818
1919import (
20- "context"
2120 "fmt"
2221 "testing"
2322 "time"
@@ -199,14 +198,14 @@ func TestReconcileNormal_WaitingForIPAddrAllocation(t *testing.T) {
199198 r := setupReconciler (fakeVMSvc )
200199 g := NewWithT (t )
201200 // First reconcile should add the paused condition
202- _ , err = r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
201+ _ , err = r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
203202 g .Expect (err ).NotTo (HaveOccurred ())
204- _ , err = r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
203+ _ , err = r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
205204 g .Expect (err ).NotTo (HaveOccurred ())
206205
207206 vm := & infrav1.VSphereVM {}
208207 vmKey := util .ObjectKey (vsphereVM )
209- g .Expect (r .Client .Get (context . Background (), vmKey , vm )).NotTo (HaveOccurred ())
208+ g .Expect (r .Client .Get (t . Context (), vmKey , vm )).NotTo (HaveOccurred ())
210209
211210 g .Expect (v1beta1conditions .Has (vm , infrav1 .VMProvisionedCondition )).To (BeTrue ())
212211 vmProvisionCondition := v1beta1conditions .Get (vm , infrav1 .VMProvisionedCondition )
@@ -235,14 +234,14 @@ func TestReconcileNormal_WaitingForIPAddrAllocation(t *testing.T) {
235234 r := setupReconciler (fakeVMSvc )
236235 g := NewWithT (t )
237236 // First reconcile should add the paused condition
238- _ , err = r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
237+ _ , err = r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
239238 g .Expect (err ).NotTo (HaveOccurred ())
240- _ , err = r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
239+ _ , err = r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
241240 g .Expect (err ).NotTo (HaveOccurred ())
242241
243242 vm := & infrav1.VSphereVM {}
244243 vmKey := util .ObjectKey (vsphereVM )
245- g .Expect (r .Client .Get (context . Background (), vmKey , vm )).NotTo (HaveOccurred ())
244+ g .Expect (r .Client .Get (t . Context (), vmKey , vm )).NotTo (HaveOccurred ())
246245
247246 g .Expect (v1beta1conditions .Has (vm , infrav1 .VMProvisionedCondition )).To (BeTrue ())
248247 vmProvisionCondition := v1beta1conditions .Get (vm , infrav1 .VMProvisionedCondition )
@@ -285,18 +284,18 @@ func TestReconcileNormal_WaitingForIPAddrAllocation(t *testing.T) {
285284 g := NewWithT (t )
286285
287286 // First reconcile should add the paused condition
288- _ , err := r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
287+ _ , err := r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
289288 g .Expect (err ).ToNot (HaveOccurred ())
290- _ , err = r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
289+ _ , err = r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
291290 g .Expect (err ).ToNot (HaveOccurred ())
292291
293292 vm := & infrav1.VSphereVM {}
294293 vmKey := util .ObjectKey (vsphereVM )
295- g .Expect (apierrors .IsNotFound (r .Client .Get (context . Background (), vmKey , vm ))).To (BeTrue ())
294+ g .Expect (apierrors .IsNotFound (r .Client .Get (t . Context (), vmKey , vm ))).To (BeTrue ())
296295
297296 claim := & ipamv1beta1.IPAddressClaim {}
298297 ipacKey := util .ObjectKey (ipAddressClaim )
299- g .Expect (r .Client .Get (context . Background (), ipacKey , claim )).NotTo (HaveOccurred ())
298+ g .Expect (r .Client .Get (t . Context (), ipacKey , claim )).NotTo (HaveOccurred ())
300299 g .Expect (claim .ObjectMeta .Finalizers ).NotTo (ContainElement (infrav1 .IPAddressClaimFinalizer ))
301300 })
302301}
@@ -369,7 +368,7 @@ func TestVmReconciler_WaitingForStaticIPAllocation(t *testing.T) {
369368 }
370369
371370 controllerManagerCtx := fake .NewControllerManagerContext ()
372- vmContext := fake .NewVMContext (context . Background (), controllerManagerCtx )
371+ vmContext := fake .NewVMContext (t . Context (), controllerManagerCtx )
373372 r := vmReconciler {ControllerManagerContext : controllerManagerCtx }
374373
375374 for _ , tt := range tests {
@@ -492,14 +491,14 @@ func TestRetrievingVCenterCredentialsFromCluster(t *testing.T) {
492491
493492 g := NewWithT (t )
494493 // First reconcile should add the paused condition
495- _ , err = r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
494+ _ , err = r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
496495 g .Expect (err ).NotTo (HaveOccurred ())
497- _ , err = r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
496+ _ , err = r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
498497 g .Expect (err ).NotTo (HaveOccurred ())
499498
500499 vm := & infrav1.VSphereVM {}
501500 vmKey := util .ObjectKey (vsphereVM )
502- g .Expect (r .Client .Get (context . Background (), vmKey , vm )).NotTo (HaveOccurred ())
501+ g .Expect (r .Client .Get (t . Context (), vmKey , vm )).NotTo (HaveOccurred ())
503502 g .Expect (v1beta1conditions .Has (vm , infrav1 .VCenterAvailableCondition )).To (BeTrue ())
504503 vCenterCondition := v1beta1conditions .Get (vm , infrav1 .VCenterAvailableCondition )
505504 g .Expect (vCenterCondition .Status ).To (Equal (corev1 .ConditionTrue ))
@@ -529,9 +528,9 @@ func TestRetrievingVCenterCredentialsFromCluster(t *testing.T) {
529528
530529 g := NewWithT (t )
531530 // First reconcile should add the paused condition
532- _ , err = r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
531+ _ , err = r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
533532 g .Expect (err ).ToNot (HaveOccurred ())
534- _ , err = r .Reconcile (context . Background (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
533+ _ , err = r .Reconcile (t . Context (), ctrl.Request {NamespacedName : util .ObjectKey (vsphereVM )})
535534 g .Expect (err ).To (HaveOccurred ())
536535 },
537536 )
0 commit comments