Skip to content

Commit 75cde08

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 5a01112 commit 75cde08

9 files changed

+29
-29
lines changed

controllers/bucket_controller_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestBucketReconciler_Reconcile(t *testing.T) {
120120
// Check if the object status is valid.
121121
condns := &conditionscheck.Conditions{NegativePolarity: bucketReadyCondition.NegativePolarity}
122122
checker := conditionscheck.NewChecker(testEnv.Client, condns)
123-
checker.CheckErr(ctx, obj)
123+
checker.WithT(g).CheckErr(ctx, obj)
124124

125125
// kstatus client conformance check.
126126
uo, err := patch.ToUnstructured(obj)
@@ -321,7 +321,7 @@ func TestBucketReconciler_reconcileStorage(t *testing.T) {
321321

322322
// In-progress status condition validity.
323323
checker := conditionscheck.NewInProgressChecker(r.Client)
324-
checker.CheckErr(ctx, obj)
324+
checker.WithT(g).CheckErr(ctx, obj)
325325
})
326326
}
327327
}
@@ -662,7 +662,7 @@ func TestBucketReconciler_reconcileSource_generic(t *testing.T) {
662662

663663
// In-progress status condition validity.
664664
checker := conditionscheck.NewInProgressChecker(r.Client)
665-
checker.CheckErr(ctx, obj)
665+
checker.WithT(g).CheckErr(ctx, obj)
666666
})
667667
}
668668
}
@@ -1022,7 +1022,7 @@ func TestBucketReconciler_reconcileSource_gcs(t *testing.T) {
10221022

10231023
// In-progress status condition validity.
10241024
checker := conditionscheck.NewInProgressChecker(r.Client)
1025-
checker.CheckErr(ctx, obj)
1025+
checker.WithT(g).CheckErr(ctx, obj)
10261026
})
10271027
}
10281028
}
@@ -1201,7 +1201,7 @@ func TestBucketReconciler_reconcileArtifact(t *testing.T) {
12011201

12021202
// In-progress status condition validity.
12031203
checker := conditionscheck.NewInProgressChecker(r.Client)
1204-
checker.CheckErr(ctx, obj)
1204+
checker.WithT(g).CheckErr(ctx, obj)
12051205
})
12061206
}
12071207
}

controllers/gitrepository_controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func TestGitRepositoryReconciler_Reconcile(t *testing.T) {
186186
// Check if the object status is valid.
187187
condns := &conditionscheck.Conditions{NegativePolarity: gitRepositoryReadyCondition.NegativePolarity}
188188
checker := conditionscheck.NewChecker(testEnv.Client, condns)
189-
checker.CheckErr(ctx, obj)
189+
checker.WithT(g).CheckErr(ctx, obj)
190190

191191
// kstatus client conformance check.
192192
u, err := patch.ToUnstructured(obj)
@@ -590,7 +590,7 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
590590

591591
// In-progress status condition validity.
592592
checker := conditionscheck.NewInProgressChecker(r.Client)
593-
checker.CheckErr(ctx, obj)
593+
checker.WithT(g).CheckErr(ctx, obj)
594594
})
595595
}
596596
}
@@ -815,7 +815,7 @@ func TestGitRepositoryReconciler_reconcileSource_checkoutStrategy(t *testing.T)
815815
}
816816
// In-progress status condition validity.
817817
checker := conditionscheck.NewInProgressChecker(r.Client)
818-
checker.CheckErr(ctx, obj)
818+
checker.WithT(g).CheckErr(ctx, obj)
819819
})
820820
}
821821
}
@@ -1374,7 +1374,7 @@ func TestGitRepositoryReconciler_reconcileStorage(t *testing.T) {
13741374

13751375
// In-progress status condition validity.
13761376
checker := conditionscheck.NewInProgressChecker(r.Client)
1377-
checker.CheckErr(ctx, obj)
1377+
checker.WithT(g).CheckErr(ctx, obj)
13781378
})
13791379
}
13801380
}

controllers/helmchart_controller_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func TestHelmChartReconciler_Reconcile(t *testing.T) {
109109
// Check if the object status is valid.
110110
condns := &conditionscheck.Conditions{NegativePolarity: helmChartReadyCondition.NegativePolarity}
111111
checker := conditionscheck.NewChecker(testEnv.Client, condns)
112-
checker.CheckErr(ctx, obj)
112+
checker.WithT(g).CheckErr(ctx, obj)
113113

114114
// kstatus client conformance check.
115115
u, err := patch.ToUnstructured(obj)
@@ -177,7 +177,7 @@ func TestHelmChartReconciler_Reconcile(t *testing.T) {
177177
// Check if the object status is valid.
178178
condns := &conditionscheck.Conditions{NegativePolarity: helmChartReadyCondition.NegativePolarity}
179179
checker := conditionscheck.NewChecker(testEnv.Client, condns)
180-
checker.CheckErr(ctx, obj)
180+
checker.WithT(g).CheckErr(ctx, obj)
181181

182182
g.Expect(testEnv.Delete(ctx, obj)).To(Succeed())
183183

@@ -212,7 +212,7 @@ func TestHelmChartReconciler_Reconcile(t *testing.T) {
212212
// Check if the object status is valid.
213213
condns := &conditionscheck.Conditions{NegativePolarity: helmChartReadyCondition.NegativePolarity}
214214
checker := conditionscheck.NewChecker(testEnv.Client, condns)
215-
checker.CheckErr(ctx, obj)
215+
checker.WithT(g).CheckErr(ctx, obj)
216216

217217
g.Expect(testEnv.Delete(ctx, obj)).To(Succeed())
218218

@@ -444,7 +444,7 @@ func TestHelmChartReconciler_reconcileStorage(t *testing.T) {
444444

445445
// In-progress status condition validity.
446446
checker := conditionscheck.NewInProgressChecker(r.Client)
447-
checker.CheckErr(ctx, obj)
447+
checker.WithT(g).CheckErr(ctx, obj)
448448
})
449449
}
450450
}
@@ -708,7 +708,7 @@ func TestHelmChartReconciler_reconcileSource(t *testing.T) {
708708

709709
// In-progress status condition validity.
710710
checker := conditionscheck.NewInProgressChecker(r.Client)
711-
checker.CheckErr(ctx, &obj)
711+
checker.WithT(g).CheckErr(ctx, &obj)
712712
})
713713
}
714714
}

controllers/helmrepository_controller_oci_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestHelmRepositoryOCIReconciler_Reconcile(t *testing.T) {
122122
// Check if the object status is valid.
123123
condns := &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity}
124124
checker := conditionscheck.NewChecker(testEnv.Client, condns)
125-
checker.CheckErr(ctx, obj)
125+
checker.WithT(g).CheckErr(ctx, obj)
126126

127127
// kstatus client conformance check.
128128
u, err := patch.ToUnstructured(obj)
@@ -316,7 +316,7 @@ func TestHelmRepositoryOCIReconciler_authStrategy(t *testing.T) {
316316
// NOTE: Check the object directly as reconcile() doesn't apply the
317317
// final patch, the object has unapplied changes.
318318
checker.DisableFetch = true
319-
checker.CheckErr(ctx, obj)
319+
checker.WithT(g).CheckErr(ctx, obj)
320320
})
321321
}
322322
}

controllers/helmrepository_controller_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func TestHelmRepositoryReconciler_Reconcile(t *testing.T) {
9494
// Check if the object status is valid.
9595
condns := &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity}
9696
checker := conditionscheck.NewChecker(testEnv.Client, condns)
97-
checker.CheckErr(ctx, obj)
97+
checker.WithT(g).CheckErr(ctx, obj)
9898

9999
// kstatus client conformance check.
100100
u, err := patch.ToUnstructured(obj)
@@ -292,7 +292,7 @@ func TestHelmRepositoryReconciler_reconcileStorage(t *testing.T) {
292292

293293
// In-progress status condition validity.
294294
checker := conditionscheck.NewInProgressChecker(r.Client)
295-
checker.CheckErr(ctx, obj)
295+
checker.WithT(g).CheckErr(ctx, obj)
296296
})
297297
}
298298
}
@@ -746,7 +746,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
746746

747747
// In-progress status condition validity.
748748
checker := conditionscheck.NewInProgressChecker(r.Client)
749-
checker.CheckErr(ctx, obj)
749+
checker.WithT(g).CheckErr(ctx, obj)
750750
})
751751
}
752752
}
@@ -1278,7 +1278,7 @@ func TestHelmRepositoryReconciler_ReconcileTypeUpdatePredicateFilter(t *testing.
12781278
// Check if the object status is valid.
12791279
condns := &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity}
12801280
checker := conditionscheck.NewChecker(testEnv.Client, condns)
1281-
checker.CheckErr(ctx, obj)
1281+
checker.WithT(g).CheckErr(ctx, obj)
12821282

12831283
// kstatus client conformance check.
12841284
u, err := patch.ToUnstructured(obj)
@@ -1330,7 +1330,7 @@ func TestHelmRepositoryReconciler_ReconcileTypeUpdatePredicateFilter(t *testing.
13301330
// Check if the object status is valid.
13311331
condns = &conditionscheck.Conditions{NegativePolarity: helmRepositoryOCINegativeConditions}
13321332
checker = conditionscheck.NewChecker(testEnv.Client, condns)
1333-
checker.CheckErr(ctx, obj)
1333+
checker.WithT(g).CheckErr(ctx, obj)
13341334

13351335
g.Expect(testEnv.Delete(ctx, obj)).To(Succeed())
13361336

@@ -1395,7 +1395,7 @@ func TestHelmRepositoryReconciler_ReconcileSpecUpdatePredicateFilter(t *testing.
13951395
// Check if the object status is valid.
13961396
condns := &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity}
13971397
checker := conditionscheck.NewChecker(testEnv.Client, condns)
1398-
checker.CheckErr(ctx, obj)
1398+
checker.WithT(g).CheckErr(ctx, obj)
13991399

14001400
// kstatus client conformance check.
14011401
u, err := patch.ToUnstructured(obj)
@@ -1427,7 +1427,7 @@ func TestHelmRepositoryReconciler_ReconcileSpecUpdatePredicateFilter(t *testing.
14271427
// Check if the object status is valid.
14281428
condns = &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity}
14291429
checker = conditionscheck.NewChecker(testEnv.Client, condns)
1430-
checker.CheckErr(ctx, obj)
1430+
checker.WithT(g).CheckErr(ctx, obj)
14311431

14321432
g.Expect(testEnv.Delete(ctx, obj)).To(Succeed())
14331433

controllers/ocirepository_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func TestOCIRepository_Reconcile(t *testing.T) {
217217
// Check if the object status is valid
218218
condns := &conditionscheck.Conditions{NegativePolarity: ociRepositoryReadyCondition.NegativePolarity}
219219
checker := conditionscheck.NewChecker(testEnv.Client, condns)
220-
checker.CheckErr(ctx, obj)
220+
checker.WithT(g).CheckErr(ctx, obj)
221221

222222
// kstatus client conformance check
223223
u, err := patch.ToUnstructured(obj)
@@ -1998,7 +1998,7 @@ func TestOCIRepository_reconcileStorage(t *testing.T) {
19981998

19991999
// In-progress status condition validity.
20002000
checker := conditionscheck.NewInProgressChecker(r.Client)
2001-
checker.CheckErr(ctx, obj)
2001+
checker.WithT(g).CheckErr(ctx, obj)
20022002
})
20032003
}
20042004
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
github.com/fluxcd/pkg/lockedfile v0.1.0
3232
github.com/fluxcd/pkg/masktoken v0.2.0
3333
github.com/fluxcd/pkg/oci v0.18.0
34-
github.com/fluxcd/pkg/runtime v0.27.0
34+
github.com/fluxcd/pkg/runtime v0.28.0
3535
github.com/fluxcd/pkg/sourceignore v0.3.0
3636
github.com/fluxcd/pkg/ssh v0.7.0
3737
github.com/fluxcd/pkg/testserver v0.4.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ github.com/fluxcd/pkg/masktoken v0.2.0 h1:HoSPTk4l1fz5Fevs2vVRvZGru33blfMwWSZKsH
541541
github.com/fluxcd/pkg/masktoken v0.2.0/go.mod h1:EA7GleAHL33kN6kTW06m5R3/Q26IyuGO7Ef/0CtpDI0=
542542
github.com/fluxcd/pkg/oci v0.18.0 h1:x5n3gW1lX6wrqvWP4ZkOXJ8LqLKy891uKwifCXSqKi4=
543543
github.com/fluxcd/pkg/oci v0.18.0/go.mod h1:zXoxvE4uuIEOgA98IM5Wv/uRxs7sdbaTlGDjzHb9yiA=
544-
github.com/fluxcd/pkg/runtime v0.27.0 h1:zVA95Z0KvNjvZxEZhvIbJyJIwtaiv1aVttHZ4YB/FzY=
545-
github.com/fluxcd/pkg/runtime v0.27.0/go.mod h1:fC1l4Wv1hnsqPKB46eDZBXF8RMZm5FXeU4bnJkwGkqk=
544+
github.com/fluxcd/pkg/runtime v0.28.0 h1:FtdZk53oMFUKIGykDtWNi3Pv2lXR6NHPWNqLQV5rpPg=
545+
github.com/fluxcd/pkg/runtime v0.28.0/go.mod h1:fC1l4Wv1hnsqPKB46eDZBXF8RMZm5FXeU4bnJkwGkqk=
546546
github.com/fluxcd/pkg/sourceignore v0.3.0 h1:pFO3hKV9ub+2SrNZPZE7xfiRhxsycRrd7JK7qB26nVw=
547547
github.com/fluxcd/pkg/sourceignore v0.3.0/go.mod h1:ak3Tve/KwVzytZ5V2yBlGGpTJ/2oQ9kcP3iuwBOAHGo=
548548
github.com/fluxcd/pkg/ssh v0.7.0 h1:FX5ky8SU9dYwbM6zEIDR3TSveLF01iyS95CtB5Ykpno=

internal/reconcile/summarize/summary_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func TestSummarizeAndPatch(t *testing.T) {
371371
// Check if the object status is valid as per kstatus.
372372
condns := &conditionscheck.Conditions{NegativePolarity: testReadyConditions.NegativePolarity}
373373
checker := conditionscheck.NewChecker(client, condns)
374-
checker.CheckErr(ctx, obj)
374+
checker.WithT(g).CheckErr(ctx, obj)
375375
})
376376
}
377377
}

0 commit comments

Comments
 (0)