Skip to content

Commit

Permalink
Merge pull request #358 from shapeblue/fixup-unit-test-failures
Browse files Browse the repository at this point in the history
Fixup unit test failures
  • Loading branch information
k8s-ci-robot authored May 24, 2024
2 parents 54c8213 + a2dd1ff commit a77adcb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions controllers/cloudstackaffinitygroup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ var _ = Describe("CloudStackAffinityGroupReconciler", func() {
// Modify failure domain name the same way the cluster controller would.
dummies.CSAffinityGroup.Spec.FailureDomainName = dummies.CSFailureDomain1.Spec.Name

mockCloudClient.EXPECT().GetOrCreateAffinityGroup(gomock.Any()).AnyTimes()

Ω(k8sClient.Create(ctx, dummies.CSFailureDomain1))
Ω(k8sClient.Create(ctx, dummies.CSAffinityGroup)).Should(Succeed())

mockCloudClient.EXPECT().GetOrCreateAffinityGroup(gomock.Any()).AnyTimes()

// Test that the AffinityGroup controller sets Status.Ready to true.
Eventually(func() bool {
nameSpaceFilter := &client.ListOptions{Namespace: dummies.ClusterNameSpace}
Expand All @@ -61,11 +61,11 @@ var _ = Describe("CloudStackAffinityGroupReconciler", func() {
// Modify failure domain name the same way the cluster controller would.
dummies.CSAffinityGroup.Spec.FailureDomainName = dummies.CSFailureDomain1.Spec.Name

mockCloudClient.EXPECT().GetOrCreateAffinityGroup(gomock.Any()).AnyTimes()

Ω(k8sClient.Create(ctx, dummies.CSFailureDomain1))
Ω(k8sClient.Create(ctx, dummies.CSAffinityGroup)).Should(Succeed())

mockCloudClient.EXPECT().GetOrCreateAffinityGroup(gomock.Any()).AnyTimes()

// Test that the AffinityGroup controller sets Status.Ready to true.
Eventually(func() bool {
nameSpaceFilter := &client.ListOptions{Namespace: dummies.ClusterNameSpace}
Expand All @@ -78,11 +78,12 @@ var _ = Describe("CloudStackAffinityGroupReconciler", func() {
return false
}, timeout).WithPolling(pollInterval).Should(BeTrue())

Ω(k8sClient.Delete(ctx, dummies.CSAffinityGroup))
mockCloudClient.EXPECT().FetchAffinityGroup(gomock.Any()).Do(func(arg1 interface{}) {
arg1.(*cloud.AffinityGroup).ID = ""
}).AnyTimes().Return(nil)

Ω(k8sClient.Delete(ctx, dummies.CSAffinityGroup))

// Once the affinity group id was set to "" the controller should remove the finalizer and unblock deleting affinity group resource
Eventually(func() bool {
retrievedAffinityGroup := &infrav1.CloudStackAffinityGroup{}
Expand Down

0 comments on commit a77adcb

Please sign in to comment.