Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup unit test failures #358

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading