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 <darkowlzz@protonmail.com>
This commit is contained in:
		
							parent
							
								
									5a01112253
								
							
						
					
					
						commit
						75cde08ff0
					
				|  | @ -120,7 +120,7 @@ func TestBucketReconciler_Reconcile(t *testing.T) { | |||
| 	// Check if the object status is valid.
 | ||||
| 	condns := &conditionscheck.Conditions{NegativePolarity: bucketReadyCondition.NegativePolarity} | ||||
| 	checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 	checker.CheckErr(ctx, obj) | ||||
| 	checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 	// kstatus client conformance check.
 | ||||
| 	uo, err := patch.ToUnstructured(obj) | ||||
|  | @ -321,7 +321,7 @@ func TestBucketReconciler_reconcileStorage(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | @ -662,7 +662,7 @@ func TestBucketReconciler_reconcileSource_generic(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | @ -1022,7 +1022,7 @@ func TestBucketReconciler_reconcileSource_gcs(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | @ -1201,7 +1201,7 @@ func TestBucketReconciler_reconcileArtifact(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -186,7 +186,7 @@ func TestGitRepositoryReconciler_Reconcile(t *testing.T) { | |||
| 	// Check if the object status is valid.
 | ||||
| 	condns := &conditionscheck.Conditions{NegativePolarity: gitRepositoryReadyCondition.NegativePolarity} | ||||
| 	checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 	checker.CheckErr(ctx, obj) | ||||
| 	checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 	// kstatus client conformance check.
 | ||||
| 	u, err := patch.ToUnstructured(obj) | ||||
|  | @ -590,7 +590,7 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | @ -815,7 +815,7 @@ func TestGitRepositoryReconciler_reconcileSource_checkoutStrategy(t *testing.T) | |||
| 			} | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | @ -1374,7 +1374,7 @@ func TestGitRepositoryReconciler_reconcileStorage(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -109,7 +109,7 @@ func TestHelmChartReconciler_Reconcile(t *testing.T) { | |||
| 				// Check if the object status is valid.
 | ||||
| 				condns := &conditionscheck.Conditions{NegativePolarity: helmChartReadyCondition.NegativePolarity} | ||||
| 				checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 				checker.CheckErr(ctx, obj) | ||||
| 				checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 				// kstatus client conformance check.
 | ||||
| 				u, err := patch.ToUnstructured(obj) | ||||
|  | @ -177,7 +177,7 @@ func TestHelmChartReconciler_Reconcile(t *testing.T) { | |||
| 				// Check if the object status is valid.
 | ||||
| 				condns := &conditionscheck.Conditions{NegativePolarity: helmChartReadyCondition.NegativePolarity} | ||||
| 				checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 				checker.CheckErr(ctx, obj) | ||||
| 				checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 				g.Expect(testEnv.Delete(ctx, obj)).To(Succeed()) | ||||
| 
 | ||||
|  | @ -212,7 +212,7 @@ func TestHelmChartReconciler_Reconcile(t *testing.T) { | |||
| 				// Check if the object status is valid.
 | ||||
| 				condns := &conditionscheck.Conditions{NegativePolarity: helmChartReadyCondition.NegativePolarity} | ||||
| 				checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 				checker.CheckErr(ctx, obj) | ||||
| 				checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 				g.Expect(testEnv.Delete(ctx, obj)).To(Succeed()) | ||||
| 
 | ||||
|  | @ -444,7 +444,7 @@ func TestHelmChartReconciler_reconcileStorage(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | @ -708,7 +708,7 @@ func TestHelmChartReconciler_reconcileSource(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, &obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, &obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -122,7 +122,7 @@ func TestHelmRepositoryOCIReconciler_Reconcile(t *testing.T) { | |||
| 			// Check if the object status is valid.
 | ||||
| 			condns := &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity} | ||||
| 			checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 			// kstatus client conformance check.
 | ||||
| 			u, err := patch.ToUnstructured(obj) | ||||
|  | @ -316,7 +316,7 @@ func TestHelmRepositoryOCIReconciler_authStrategy(t *testing.T) { | |||
| 			// NOTE: Check the object directly as reconcile() doesn't apply the
 | ||||
| 			// final patch, the object has unapplied changes.
 | ||||
| 			checker.DisableFetch = true | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -94,7 +94,7 @@ func TestHelmRepositoryReconciler_Reconcile(t *testing.T) { | |||
| 	// Check if the object status is valid.
 | ||||
| 	condns := &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity} | ||||
| 	checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 	checker.CheckErr(ctx, obj) | ||||
| 	checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 	// kstatus client conformance check.
 | ||||
| 	u, err := patch.ToUnstructured(obj) | ||||
|  | @ -292,7 +292,7 @@ func TestHelmRepositoryReconciler_reconcileStorage(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | @ -746,7 +746,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | @ -1278,7 +1278,7 @@ func TestHelmRepositoryReconciler_ReconcileTypeUpdatePredicateFilter(t *testing. | |||
| 	// Check if the object status is valid.
 | ||||
| 	condns := &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity} | ||||
| 	checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 	checker.CheckErr(ctx, obj) | ||||
| 	checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 	// kstatus client conformance check.
 | ||||
| 	u, err := patch.ToUnstructured(obj) | ||||
|  | @ -1330,7 +1330,7 @@ func TestHelmRepositoryReconciler_ReconcileTypeUpdatePredicateFilter(t *testing. | |||
| 	// Check if the object status is valid.
 | ||||
| 	condns = &conditionscheck.Conditions{NegativePolarity: helmRepositoryOCINegativeConditions} | ||||
| 	checker = conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 	checker.CheckErr(ctx, obj) | ||||
| 	checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 	g.Expect(testEnv.Delete(ctx, obj)).To(Succeed()) | ||||
| 
 | ||||
|  | @ -1395,7 +1395,7 @@ func TestHelmRepositoryReconciler_ReconcileSpecUpdatePredicateFilter(t *testing. | |||
| 	// Check if the object status is valid.
 | ||||
| 	condns := &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity} | ||||
| 	checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 	checker.CheckErr(ctx, obj) | ||||
| 	checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 	// kstatus client conformance check.
 | ||||
| 	u, err := patch.ToUnstructured(obj) | ||||
|  | @ -1427,7 +1427,7 @@ func TestHelmRepositoryReconciler_ReconcileSpecUpdatePredicateFilter(t *testing. | |||
| 	// Check if the object status is valid.
 | ||||
| 	condns = &conditionscheck.Conditions{NegativePolarity: helmRepositoryReadyCondition.NegativePolarity} | ||||
| 	checker = conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 	checker.CheckErr(ctx, obj) | ||||
| 	checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 	g.Expect(testEnv.Delete(ctx, obj)).To(Succeed()) | ||||
| 
 | ||||
|  |  | |||
|  | @ -217,7 +217,7 @@ func TestOCIRepository_Reconcile(t *testing.T) { | |||
| 			// Check if the object status is valid
 | ||||
| 			condns := &conditionscheck.Conditions{NegativePolarity: ociRepositoryReadyCondition.NegativePolarity} | ||||
| 			checker := conditionscheck.NewChecker(testEnv.Client, condns) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 
 | ||||
| 			// kstatus client conformance check
 | ||||
| 			u, err := patch.ToUnstructured(obj) | ||||
|  | @ -1998,7 +1998,7 @@ func TestOCIRepository_reconcileStorage(t *testing.T) { | |||
| 
 | ||||
| 			// In-progress status condition validity.
 | ||||
| 			checker := conditionscheck.NewInProgressChecker(r.Client) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
							
								
								
									
										2
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										2
									
								
								go.mod
								
								
								
								
							|  | @ -31,7 +31,7 @@ require ( | |||
| 	github.com/fluxcd/pkg/lockedfile v0.1.0 | ||||
| 	github.com/fluxcd/pkg/masktoken v0.2.0 | ||||
| 	github.com/fluxcd/pkg/oci v0.18.0 | ||||
| 	github.com/fluxcd/pkg/runtime v0.27.0 | ||||
| 	github.com/fluxcd/pkg/runtime v0.28.0 | ||||
| 	github.com/fluxcd/pkg/sourceignore v0.3.0 | ||||
| 	github.com/fluxcd/pkg/ssh v0.7.0 | ||||
| 	github.com/fluxcd/pkg/testserver v0.4.0 | ||||
|  |  | |||
							
								
								
									
										4
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										4
									
								
								go.sum
								
								
								
								
							|  | @ -541,8 +541,8 @@ github.com/fluxcd/pkg/masktoken v0.2.0 h1:HoSPTk4l1fz5Fevs2vVRvZGru33blfMwWSZKsH | |||
| github.com/fluxcd/pkg/masktoken v0.2.0/go.mod h1:EA7GleAHL33kN6kTW06m5R3/Q26IyuGO7Ef/0CtpDI0= | ||||
| github.com/fluxcd/pkg/oci v0.18.0 h1:x5n3gW1lX6wrqvWP4ZkOXJ8LqLKy891uKwifCXSqKi4= | ||||
| github.com/fluxcd/pkg/oci v0.18.0/go.mod h1:zXoxvE4uuIEOgA98IM5Wv/uRxs7sdbaTlGDjzHb9yiA= | ||||
| github.com/fluxcd/pkg/runtime v0.27.0 h1:zVA95Z0KvNjvZxEZhvIbJyJIwtaiv1aVttHZ4YB/FzY= | ||||
| github.com/fluxcd/pkg/runtime v0.27.0/go.mod h1:fC1l4Wv1hnsqPKB46eDZBXF8RMZm5FXeU4bnJkwGkqk= | ||||
| github.com/fluxcd/pkg/runtime v0.28.0 h1:FtdZk53oMFUKIGykDtWNi3Pv2lXR6NHPWNqLQV5rpPg= | ||||
| github.com/fluxcd/pkg/runtime v0.28.0/go.mod h1:fC1l4Wv1hnsqPKB46eDZBXF8RMZm5FXeU4bnJkwGkqk= | ||||
| github.com/fluxcd/pkg/sourceignore v0.3.0 h1:pFO3hKV9ub+2SrNZPZE7xfiRhxsycRrd7JK7qB26nVw= | ||||
| github.com/fluxcd/pkg/sourceignore v0.3.0/go.mod h1:ak3Tve/KwVzytZ5V2yBlGGpTJ/2oQ9kcP3iuwBOAHGo= | ||||
| github.com/fluxcd/pkg/ssh v0.7.0 h1:FX5ky8SU9dYwbM6zEIDR3TSveLF01iyS95CtB5Ykpno= | ||||
|  |  | |||
|  | @ -371,7 +371,7 @@ func TestSummarizeAndPatch(t *testing.T) { | |||
| 			// Check if the object status is valid as per kstatus.
 | ||||
| 			condns := &conditionscheck.Conditions{NegativePolarity: testReadyConditions.NegativePolarity} | ||||
| 			checker := conditionscheck.NewChecker(client, condns) | ||||
| 			checker.CheckErr(ctx, obj) | ||||
| 			checker.WithT(g).CheckErr(ctx, obj) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue