From 8a490263dd7cf7f230a51943c945ddd15f7f5fd4 Mon Sep 17 00:00:00 2001 From: Bella Bai Date: Tue, 23 Jan 2024 17:07:54 -0500 Subject: [PATCH] Add another test for codecov to be happy --- reconcilers/cast_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/reconcilers/cast_test.go b/reconcilers/cast_test.go index 522e5ec..ee47e53 100644 --- a/reconcilers/cast_test.go +++ b/reconcilers/cast_test.go @@ -183,6 +183,46 @@ func TestCastResource(t *testing.T) { }, ShouldErr: true, }, + "cast mutation patch error": { + Resource: resource.DieReleasePtr(), + Metadata: map[string]interface{}{ + "SubReconciler": func(t *testing.T, c reconcilers.Config) reconcilers.SubReconciler[*resources.TestResource] { + return &reconcilers.CastResource[*resources.TestResource, *resources.TestResource]{ + Reconciler: &reconcilers.SyncReconciler[*resources.TestResource]{ + Sync: func(ctx context.Context, r *resources.TestResource) error { + r.Spec.ErrOnMarshal = true + return fmt.Errorf("subreconciler error") + }, + }, + } + }, + }, + ShouldErr: true, + }, + "cast mutation patch apply error": { + Resource: resource.DieReleasePtr(), + Metadata: map[string]interface{}{ + "SubReconciler": func(t *testing.T, c reconcilers.Config) reconcilers.SubReconciler[*resources.TestResource] { + return &reconcilers.CastResource[*resources.TestResource, *resources.TestResource]{ + Reconciler: &reconcilers.SyncReconciler[*resources.TestResource]{ + Sync: func(ctx context.Context, r *resources.TestResource) error { + r.Spec.ErrOnUnmarshal = true + return fmt.Errorf("subreconciler error") + }, + }, + } + }, + }, + ExpectResource: resource. + SpecDie(func(d *dies.TestResourceSpecDie) { + d.ErrOnUnmarshal(true) + }). + StatusDie(func(d *dies.TestResourceStatusDie) { + d.ConditionsDie() // The unmarshal error would result in losing the initializing Ready condition during applying the patch + }). + DieReleasePtr(), + ShouldErr: true, + }, } rts.Run(t, scheme, func(t *testing.T, rtc *rtesting.SubReconcilerTestCase[*resources.TestResource], c reconcilers.Config) reconcilers.SubReconciler[*resources.TestResource] {