Skip to content

Commit c612504

Browse files
committed
Use condition checker with gomega WithT
This allows using the condition checker as a test helper with proper test like assertion failure and stacktrace. Signed-off-by: Sunny <[email protected]>
1 parent 45aba88 commit c612504

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

controllers/policy_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func TestImagePolicyReconciler_calculateImageFromRepoTags(t *testing.T) {
234234
// Check if the object status is valid.
235235
condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions}
236236
checker := conditionscheck.NewChecker(testEnv.Client, condns)
237-
checker.CheckErr(ctx, &pol)
237+
checker.WithT(g).CheckErr(ctx, &pol)
238238

239239
g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed())
240240
})
@@ -344,7 +344,7 @@ func TestImagePolicyReconciler_filterTags(t *testing.T) {
344344
// Check if the object status is valid.
345345
condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions}
346346
checker := conditionscheck.NewChecker(testEnv.Client, condns)
347-
checker.CheckErr(ctx, &pol)
347+
checker.WithT(g).CheckErr(ctx, &pol)
348348

349349
g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed())
350350
})
@@ -519,7 +519,7 @@ func TestImagePolicyReconciler_accessImageRepo(t *testing.T) {
519519
// Check if the object status is valid.
520520
condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions}
521521
checker := conditionscheck.NewChecker(testEnv.Client, condns)
522-
checker.CheckErr(ctx, &pol)
522+
checker.WithT(g).CheckErr(ctx, &pol)
523523

524524
g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed())
525525
})

controllers/scan_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestImageRepositoryReconciler_canonicalImageName(t *testing.T) {
7979
// Check if the object status is valid.
8080
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
8181
checker := conditionscheck.NewChecker(testEnv.Client, condns)
82-
checker.CheckErr(ctx, &repo)
82+
checker.WithT(g).CheckErr(ctx, &repo)
8383

8484
// Cleanup.
8585
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -149,7 +149,7 @@ func TestImageRepositoryReconciler_fetchImageTags(t *testing.T) {
149149
// Check if the object status is valid.
150150
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
151151
checker := conditionscheck.NewChecker(testEnv.Client, condns)
152-
checker.CheckErr(ctx, &repo)
152+
checker.WithT(g).CheckErr(ctx, &repo)
153153

154154
// Cleanup.
155155
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -251,7 +251,7 @@ func TestImageRepositoryReconciler_reconcileAtAnnotation(t *testing.T) {
251251
// Check if the object status is valid.
252252
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
253253
checker := conditionscheck.NewChecker(testEnv.Client, condns)
254-
checker.CheckErr(ctx, &repo)
254+
checker.WithT(g).CheckErr(ctx, &repo)
255255

256256
// Cleanup.
257257
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -327,7 +327,7 @@ func TestImageRepositoryReconciler_authRegistry(t *testing.T) {
327327
// Check if the object status is valid.
328328
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
329329
checker := conditionscheck.NewChecker(testEnv.Client, condns)
330-
checker.CheckErr(ctx, &repo)
330+
checker.WithT(g).CheckErr(ctx, &repo)
331331

332332
// Cleanup.
333333
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -372,7 +372,7 @@ func TestImageRepositoryReconciler_imageAttribute_schemePrefix(t *testing.T) {
372372
// Check if the object status is valid.
373373
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
374374
checker := conditionscheck.NewChecker(testEnv.Client, condns)
375-
checker.CheckErr(ctx, &repo)
375+
checker.WithT(g).CheckErr(ctx, &repo)
376376

377377
// Cleanup.
378378
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -417,7 +417,7 @@ func TestImageRepositoryReconciler_imageAttribute_withTag(t *testing.T) {
417417
// Check if the object status is valid.
418418
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
419419
checker := conditionscheck.NewChecker(testEnv.Client, condns)
420-
checker.CheckErr(ctx, &repo)
420+
checker.WithT(g).CheckErr(ctx, &repo)
421421

422422
// Cleanup.
423423
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -460,7 +460,7 @@ func TestImageRepositoryReconciler_imageAttribute_hostPort(t *testing.T) {
460460
// Check if the object status is valid.
461461
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
462462
checker := conditionscheck.NewChecker(testEnv.Client, condns)
463-
checker.CheckErr(ctx, &repo)
463+
checker.WithT(g).CheckErr(ctx, &repo)
464464

465465
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
466466
}
@@ -541,7 +541,7 @@ func TestImageRepositoryReconciler_authRegistryWithServiceAccount(t *testing.T)
541541
// Check if the object status is valid.
542542
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
543543
checker := conditionscheck.NewChecker(testEnv.Client, condns)
544-
checker.CheckErr(ctx, &repo)
544+
checker.WithT(g).CheckErr(ctx, &repo)
545545

546546
// Cleanup.
547547
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -585,7 +585,7 @@ func TestImageRepositoryReconciler_ScanPublicRepos(t *testing.T) {
585585
// Check if the object status is valid.
586586
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
587587
checker := conditionscheck.NewChecker(testEnv.Client, condns)
588-
checker.CheckErr(ctx, &repo)
588+
checker.WithT(g).CheckErr(ctx, &repo)
589589

590590
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
591591
})

0 commit comments

Comments
 (0)