Skip to content

Commit

Permalink
HetznerBareMetalRemediation: Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Aniruddha Basak <aniruddha.basak@syself.com>
  • Loading branch information
aniruddha2000 committed Oct 12, 2023
1 parent ef963f8 commit d29991e
Show file tree
Hide file tree
Showing 5 changed files with 310 additions and 35 deletions.
4 changes: 4 additions & 0 deletions controllers/controllers_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ var _ = BeforeSuite(func() {
HCloudClientFactory: testEnv.HCloudClientFactory,
}).SetupWithManager(ctx, testEnv.Manager, controller.Options{})).To(Succeed())

Expect((&HetznerBareMetalRemediationReconciler{
Client: testEnv.Manager.GetClient(),
}).SetupWithManager(ctx, testEnv.Manager, controller.Options{})).To(Succeed())

go func() {
defer GinkgoRecover()
Expect(testEnv.StartManager(ctx)).To(Succeed())
Expand Down
19 changes: 18 additions & 1 deletion controllers/hcloudremediation_controller_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2023 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers

import (
Expand Down Expand Up @@ -217,7 +233,8 @@ var _ = Describe("HCloudRemediationReconciler", func() {
return false
}

return hcloudRemediation.Status.Phase == infrav1.PhaseDeleting && isPresentAndFalseWithReason(capiMachineKey, capiMachine, clusterv1.MachineOwnerRemediatedCondition, clusterv1.WaitingForRemediationReason)
return hcloudRemediation.Status.Phase == infrav1.PhaseDeleting &&
isPresentAndFalseWithReason(capiMachineKey, capiMachine, clusterv1.MachineOwnerRemediatedCondition, clusterv1.WaitingForRemediationReason)
}, timeout).Should(BeTrue())
})

Expand Down
1 change: 0 additions & 1 deletion controllers/hetznerbaremetalremediation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ func (r *HetznerBareMetalRemediationReconciler) Reconcile(ctx context.Context, r
// Nothing to do
return reconcile.Result{}, nil
}

return r.reconcileNormal(ctx, remediationScope)
}

Expand Down
Loading

0 comments on commit d29991e

Please sign in to comment.