@@ -224,12 +224,16 @@ var _ = Describe("Cloud config sync controller", func() {
224
224
co := & configv1.ClusterOperator {}
225
225
err := cl .Get (context .Background (), client.ObjectKey {Name : clusterOperatorName }, co )
226
226
if err == nil || ! apierrors .IsNotFound (err ) {
227
- Eventually (func () bool {
228
- err := cl .Delete (context .Background (), co )
229
- return err == nil || apierrors .IsNotFound (err )
230
- }).Should (BeTrue ())
227
+ Eventually (func () error {
228
+ return cl .Delete (context .Background (), co )
229
+ }).Should (SatisfyAny (
230
+ Not (HaveOccurred ()),
231
+ MatchError (apierrors .IsNotFound , "IsNotFound" ),
232
+ ))
231
233
}
232
- Eventually (apierrors .IsNotFound (cl .Get (context .Background (), client.ObjectKey {Name : clusterOperatorName }, co ))).Should (BeTrue ())
234
+ Eventually (func () error {
235
+ return cl .Get (context .Background (), client.ObjectKey {Name : clusterOperatorName }, co )
236
+ }).Should (MatchError (apierrors .IsNotFound , "IsNotFound" ))
233
237
234
238
By ("Cleanup resources" )
235
239
deleteOptions := & client.DeleteOptions {
@@ -240,27 +244,26 @@ var _ = Describe("Cloud config sync controller", func() {
240
244
Expect (cl .List (ctx , allCMs )).To (Succeed ())
241
245
for _ , cm := range allCMs .Items {
242
246
Expect (cl .Delete (ctx , cm .DeepCopy (), deleteOptions )).To (Succeed ())
243
- Eventually (
244
- apierrors . IsNotFound ( cl .Get (ctx , client .ObjectKeyFromObject (cm .DeepCopy ()), & corev1.ConfigMap {})),
245
- ).Should (BeTrue ( ))
247
+ Eventually (func () error {
248
+ return cl .Get (ctx , client .ObjectKeyFromObject (cm .DeepCopy ()), & corev1.ConfigMap {})
249
+ } ).Should (MatchError ( apierrors . IsNotFound , "IsNotFound" ))
246
250
}
247
251
248
252
infraCloudConfig = nil
249
253
managedCloudConfig = nil
250
254
251
255
infra := makeInfrastructureResource (configv1 .AzurePlatformType )
252
256
Expect (cl .Delete (ctx , infra )).To (Succeed ())
253
- Eventually (
254
- apierrors . IsNotFound ( cl .Get (ctx , client .ObjectKeyFromObject (infra ), infra )),
255
- ).Should (BeTrue ( ))
257
+ Eventually (func () error {
258
+ return cl .Get (ctx , client .ObjectKeyFromObject (infra ), infra )
259
+ } ).Should (MatchError ( apierrors . IsNotFound , "IsNotFound" ))
256
260
257
261
networkResource := makeNetworkResource ()
258
262
Expect (cl .Delete (ctx , networkResource )).To (Succeed ())
259
263
260
- Eventually (func () bool {
261
- err := cl .Get (ctx , client .ObjectKeyFromObject (networkResource ), networkResource )
262
- return apierrors .IsNotFound (err )
263
- }).Should (BeTrue (), "Expected not found error" )
264
+ Eventually (func () error {
265
+ return cl .Get (ctx , client .ObjectKeyFromObject (networkResource ), networkResource )
266
+ }).Should (MatchError (apierrors .IsNotFound , "IsNotFound" ))
264
267
})
265
268
266
269
It ("config should be synced up after first reconcile" , func () {
@@ -302,13 +305,11 @@ var _ = Describe("Cloud config sync controller", func() {
302
305
}).Should (Equal (defaultAzureConfig ))
303
306
304
307
Expect (cl .Delete (ctx , syncedCloudConfigMap )).To (Succeed ())
305
- Eventually (func () ( bool , error ) {
308
+ Eventually (func (g Gomega ) string {
306
309
err := cl .Get (ctx , syncedConfigMapKey , syncedCloudConfigMap )
307
- if err != nil {
308
- return false , err
309
- }
310
- return syncedCloudConfigMap .Data [defaultConfigKey ] == defaultAzureConfig , nil
311
- }).Should (BeTrue ())
310
+ g .Expect (err ).NotTo (HaveOccurred ())
311
+ return syncedCloudConfigMap .Data [defaultConfigKey ]
312
+ }).Should (Equal (defaultAzureConfig ))
312
313
})
313
314
314
315
It ("config should not be updated if source and target config content are identical" , func () {
@@ -463,12 +464,16 @@ var _ = Describe("Cloud config sync reconciler", func() {
463
464
co := & configv1.ClusterOperator {}
464
465
err := cl .Get (context .Background (), client.ObjectKey {Name : clusterOperatorName }, co )
465
466
if err == nil || ! apierrors .IsNotFound (err ) {
466
- Eventually (func () bool {
467
- err := cl .Delete (context .Background (), co )
468
- return err == nil || apierrors .IsNotFound (err )
469
- }).Should (BeTrue ())
467
+ Eventually (func () error {
468
+ return cl .Delete (context .Background (), co )
469
+ }).Should (SatisfyAny (
470
+ Not (HaveOccurred ()),
471
+ MatchError (apierrors .IsNotFound , "IsNotFound" ),
472
+ ))
470
473
}
471
- Eventually (apierrors .IsNotFound (cl .Get (context .Background (), client.ObjectKey {Name : clusterOperatorName }, co ))).Should (BeTrue ())
474
+ Eventually (func () error {
475
+ return cl .Get (context .Background (), client.ObjectKey {Name : clusterOperatorName }, co )
476
+ }).Should (MatchError (apierrors .IsNotFound , "IsNotFound" ))
472
477
473
478
infra := & configv1.Infrastructure {
474
479
ObjectMeta : metav1.ObjectMeta {
@@ -477,25 +482,24 @@ var _ = Describe("Cloud config sync reconciler", func() {
477
482
}
478
483
// omitted error intentionally, 404 might be there for some cases
479
484
cl .Delete (ctx , infra ) //nolint:errcheck
480
- Eventually (
481
- apierrors . IsNotFound ( cl .Get (ctx , client .ObjectKeyFromObject (infra ), infra )),
482
- ).Should (BeTrue ( ))
485
+ Eventually (func () error {
486
+ return cl .Get (ctx , client .ObjectKeyFromObject (infra ), infra )
487
+ } ).Should (MatchError ( apierrors . IsNotFound , "IsNotFound" ))
483
488
484
489
networkResource := makeNetworkResource ()
485
490
Expect (cl .Delete (ctx , networkResource )).To (Succeed ())
486
491
487
- Eventually (func () bool {
488
- err := cl .Get (ctx , client .ObjectKeyFromObject (networkResource ), networkResource )
489
- return apierrors .IsNotFound (err )
490
- }).Should (BeTrue (), "Expected not found error" )
492
+ Eventually (func () error {
493
+ return cl .Get (ctx , client .ObjectKeyFromObject (networkResource ), networkResource )
494
+ }).Should (MatchError (apierrors .IsNotFound , "IsNotFound" ))
491
495
492
496
allCMs := & corev1.ConfigMapList {}
493
497
Expect (cl .List (ctx , allCMs )).To (Succeed ())
494
498
for _ , cm := range allCMs .Items {
495
499
Expect (cl .Delete (ctx , cm .DeepCopy (), deleteOptions )).To (Succeed ())
496
- Eventually (
497
- apierrors . IsNotFound ( cl .Get (ctx , client .ObjectKeyFromObject (cm .DeepCopy ()), & corev1.ConfigMap {})),
498
- ).Should (BeTrue ( ))
500
+ Eventually (func () error {
501
+ return cl .Get (ctx , client .ObjectKeyFromObject (cm .DeepCopy ()), & corev1.ConfigMap {})
502
+ } ).Should (MatchError ( apierrors . IsNotFound , "IsNotFound" ))
499
503
}
500
504
})
501
505
})
0 commit comments