Skip to content

Commit 1761736

Browse files
author
Nick Barber
committed
Fix finalizer tests
1 parent 95e1966 commit 1761736

11 files changed

+126
-126
lines changed

controllers/binding_controller_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,21 @@ var _ = Describe("bindingController", func() {
198198
})
199199
})
200200
})
201+
202+
Context("finalizer", func() {
203+
BeforeEach(func() {
204+
bindingName = "finalizer-test"
205+
})
206+
207+
It("sets the correct deletion finalizer to the object", func() {
208+
Expect(client.Create(ctx, &binding)).To(Succeed())
209+
Eventually(func() []string {
210+
var fetched topology.Binding
211+
Expect(client.Get(ctx, types.NamespacedName{Name: binding.Name, Namespace: binding.Namespace}, &fetched)).To(Succeed())
212+
return fetched.ObjectMeta.Finalizers
213+
}, 5).Should(ConsistOf("deletion.finalizers.bindings.rabbitmq.com"))
214+
})
215+
})
201216
})
202217

203218
When("a binding references a cluster from a prohibited namespace", func() {
@@ -235,21 +250,6 @@ var _ = Describe("bindingController", func() {
235250
})
236251
})
237252

238-
Context("finalizer", func() {
239-
BeforeEach(func() {
240-
bindingName = "finalizer-test"
241-
})
242-
243-
It("sets the correct deletion finalizer to the object", func() {
244-
Expect(client.Create(ctx, &binding)).To(Succeed())
245-
Eventually(func() []string {
246-
var fetched topology.Binding
247-
Expect(client.Get(ctx, types.NamespacedName{Name: binding.Name, Namespace: binding.Namespace}, &fetched)).To(Succeed())
248-
return fetched.ObjectMeta.Finalizers
249-
}, 5).Should(ConsistOf("deletion.finalizers.bindings.rabbitmq.com"))
250-
})
251-
})
252-
253253
When("a binding references a cluster from an allowed namespace", func() {
254254
JustBeforeEach(func() {
255255
bindingName = "test-binding-allowed"

controllers/exchange_controller_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,20 @@ var _ = Describe("exchange-controller", func() {
198198
})
199199
})
200200
})
201-
})
202201

203-
Context("finalizer", func() {
204-
BeforeEach(func() {
205-
exchangeName = "finalizer-test"
206-
})
202+
Context("finalizer", func() {
203+
BeforeEach(func() {
204+
exchangeName = "finalizer-test"
205+
})
207206

208-
It("sets the correct deletion finalizer to the object", func() {
209-
Expect(client.Create(ctx, &exchange)).To(Succeed())
210-
Eventually(func() []string {
211-
var fetched topology.Exchange
212-
Expect(client.Get(ctx, types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, &fetched)).To(Succeed())
213-
return fetched.ObjectMeta.Finalizers
214-
}, 5).Should(ConsistOf("deletion.finalizers.exchanges.rabbitmq.com"))
207+
It("sets the correct deletion finalizer to the object", func() {
208+
Expect(client.Create(ctx, &exchange)).To(Succeed())
209+
Eventually(func() []string {
210+
var fetched topology.Exchange
211+
Expect(client.Get(ctx, types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, &fetched)).To(Succeed())
212+
return fetched.ObjectMeta.Finalizers
213+
}, 5).Should(ConsistOf("deletion.finalizers.exchanges.rabbitmq.com"))
214+
})
215215
})
216216
})
217217

controllers/federation_controller_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,20 @@ var _ = Describe("federation-controller", func() {
201201
})
202202
})
203203
})
204-
})
205204

206-
Context("finalizer", func() {
207-
BeforeEach(func() {
208-
name = "finalizer-test"
209-
})
205+
Context("finalizer", func() {
206+
BeforeEach(func() {
207+
federationName = "finalizer-test"
208+
})
210209

211-
It("sets the correct deletion finalizer to the object", func() {
212-
Expect(client.Create(ctx, &federation)).To(Succeed())
213-
Eventually(func() []string {
214-
var fetched topology.Federation
215-
Expect(client.Get(ctx, types.NamespacedName{Name: federation.Name, Namespace: federation.Namespace}, &fetched)).To(Succeed())
216-
return fetched.ObjectMeta.Finalizers
217-
}, 5).Should(ConsistOf("deletion.finalizers.federations.rabbitmq.com"))
210+
It("sets the correct deletion finalizer to the object", func() {
211+
Expect(client.Create(ctx, &federation)).To(Succeed())
212+
Eventually(func() []string {
213+
var fetched topology.Federation
214+
Expect(client.Get(ctx, types.NamespacedName{Name: federation.Name, Namespace: federation.Namespace}, &fetched)).To(Succeed())
215+
return fetched.ObjectMeta.Finalizers
216+
}, 5).Should(ConsistOf("deletion.finalizers.federations.rabbitmq.com"))
217+
})
218218
})
219219
})
220220

controllers/permission_controller_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,20 @@ var _ = Describe("permission-controller", func() {
197197
})
198198
})
199199
})
200-
})
201200

202-
Context("finalizer", func() {
203-
BeforeEach(func() {
204-
permissionName = "finalizer-test"
205-
})
201+
Context("finalizer", func() {
202+
BeforeEach(func() {
203+
permissionName = "finalizer-test"
204+
})
206205

207-
It("sets the correct deletion finalizer to the object", func() {
208-
Expect(client.Create(ctx, &permission)).To(Succeed())
209-
Eventually(func() []string {
210-
var fetched topology.Permission
211-
Expect(client.Get(ctx, types.NamespacedName{Name: permission.Name, Namespace: permission.Namespace}, &fetched)).To(Succeed())
212-
return fetched.ObjectMeta.Finalizers
213-
}, 5).Should(ConsistOf("deletion.finalizers.permissions.rabbitmq.com"))
206+
It("sets the correct deletion finalizer to the object", func() {
207+
Expect(client.Create(ctx, &permission)).To(Succeed())
208+
Eventually(func() []string {
209+
var fetched topology.Permission
210+
Expect(client.Get(ctx, types.NamespacedName{Name: permission.Name, Namespace: permission.Namespace}, &fetched)).To(Succeed())
211+
return fetched.ObjectMeta.Finalizers
212+
}, 5).Should(ConsistOf("deletion.finalizers.permissions.rabbitmq.com"))
213+
})
214214
})
215215
})
216216

controllers/policy_controller_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,20 @@ var _ = Describe("policy-controller", func() {
203203
})
204204
})
205205
})
206-
})
207206

208-
Context("finalizer", func() {
209-
BeforeEach(func() {
210-
policyName = "finalizer-test"
211-
})
207+
Context("finalizer", func() {
208+
BeforeEach(func() {
209+
policyName = "finalizer-test"
210+
})
212211

213-
It("sets the correct deletion finalizer to the object", func() {
214-
Expect(client.Create(ctx, &policy)).To(Succeed())
215-
Eventually(func() []string {
216-
var fetched topology.Policy
217-
Expect(client.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &fetched)).To(Succeed())
218-
return fetched.ObjectMeta.Finalizers
219-
}, 5).Should(ConsistOf("deletion.finalizers.policies.rabbitmq.com"))
212+
It("sets the correct deletion finalizer to the object", func() {
213+
Expect(client.Create(ctx, &policy)).To(Succeed())
214+
Eventually(func() []string {
215+
var fetched topology.Policy
216+
Expect(client.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &fetched)).To(Succeed())
217+
return fetched.ObjectMeta.Finalizers
218+
}, 5).Should(ConsistOf("deletion.finalizers.policies.rabbitmq.com"))
219+
})
220220
})
221221
})
222222

controllers/queue_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (r *QueueReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
9797
return ctrl.Result{}, r.deleteQueue(ctx, rabbitClient, queue)
9898
}
9999

100-
if err := addFinalizerIfNeeded(ctx, r.Client, q); err != nil {
100+
if err := addFinalizerIfNeeded(ctx, r.Client, queue); err != nil {
101101
return ctrl.Result{}, err
102102
}
103103

@@ -170,8 +170,8 @@ func (r *QueueReconciler) deleteQueue(ctx context.Context, client internal.Rabbi
170170
logger.Error(err, msg, "queue", queue.Spec.Name)
171171
return err
172172
}
173-
r.Recorder.Event(q, corev1.EventTypeNormal, "SuccessfulDelete", "successfully deleted queue")
174-
return removeFinalizer(ctx, r.Client, q)
173+
r.Recorder.Event(queue, corev1.EventTypeNormal, "SuccessfulDelete", "successfully deleted queue")
174+
return removeFinalizer(ctx, r.Client, queue)
175175
}
176176

177177
func (r *QueueReconciler) SetupWithManager(mgr ctrl.Manager) error {

controllers/queue_controller_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,20 @@ var _ = Describe("queue-controller", func() {
198198
})
199199
})
200200
})
201-
})
202201

203-
Context("finalizer", func() {
204-
BeforeEach(func() {
205-
qName = "finalizer-test"
206-
})
202+
Context("finalizer", func() {
203+
BeforeEach(func() {
204+
queueName = "finalizer-test"
205+
})
207206

208-
It("sets the correct deletion finalizer to the object", func() {
209-
Expect(client.Create(ctx, &q)).To(Succeed())
210-
Eventually(func() []string {
211-
var fetched topology.Queue
212-
Expect(client.Get(ctx, types.NamespacedName{Name: q.Name, Namespace: q.Namespace}, &fetched)).To(Succeed())
213-
return fetched.ObjectMeta.Finalizers
214-
}, 5).Should(ConsistOf("deletion.finalizers.queues.rabbitmq.com"))
207+
It("sets the correct deletion finalizer to the object", func() {
208+
Expect(client.Create(ctx, &queue)).To(Succeed())
209+
Eventually(func() []string {
210+
var fetched topology.Queue
211+
Expect(client.Get(ctx, types.NamespacedName{Name: queue.Name, Namespace: queue.Namespace}, &fetched)).To(Succeed())
212+
return fetched.ObjectMeta.Finalizers
213+
}, 5).Should(ConsistOf("deletion.finalizers.queues.rabbitmq.com"))
214+
})
215215
})
216216
})
217217

controllers/schemareplication_controller_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,20 @@ var _ = Describe("schema-replication-controller", func() {
201201
})
202202
})
203203
})
204-
})
205204

206-
Context("finalizer", func() {
207-
BeforeEach(func() {
208-
name = "finalizer-test"
209-
})
205+
Context("finalizer", func() {
206+
BeforeEach(func() {
207+
replicationName = "finalizer-test"
208+
})
210209

211-
It("sets the correct deletion finalizer to the object", func() {
212-
Expect(client.Create(ctx, &replication)).To(Succeed())
213-
Eventually(func() []string {
214-
var fetched topology.SchemaReplication
215-
Expect(client.Get(ctx, types.NamespacedName{Name: replication.Name, Namespace: replication.Namespace}, &fetched)).To(Succeed())
216-
return fetched.ObjectMeta.Finalizers
217-
}, 5).Should(ConsistOf("deletion.finalizers.schemareplications.rabbitmq.com"))
210+
It("sets the correct deletion finalizer to the object", func() {
211+
Expect(client.Create(ctx, &replication)).To(Succeed())
212+
Eventually(func() []string {
213+
var fetched topology.SchemaReplication
214+
Expect(client.Get(ctx, types.NamespacedName{Name: replication.Name, Namespace: replication.Namespace}, &fetched)).To(Succeed())
215+
return fetched.ObjectMeta.Finalizers
216+
}, 5).Should(ConsistOf("deletion.finalizers.schemareplications.rabbitmq.com"))
217+
})
218218
})
219219
})
220220

controllers/shovel_controller_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,20 @@ var _ = Describe("shovel-controller", func() {
201201
})
202202
})
203203
})
204-
})
205204

206-
Context("finalizer", func() {
207-
BeforeEach(func() {
208-
name = "finalizer-test"
209-
})
205+
Context("finalizer", func() {
206+
BeforeEach(func() {
207+
shovelName = "finalizer-test"
208+
})
210209

211-
It("sets the correct deletion finalizer to the object", func() {
212-
Expect(client.Create(ctx, &shovel)).To(Succeed())
213-
Eventually(func() []string {
214-
var fetched topology.Shovel
215-
Expect(client.Get(ctx, types.NamespacedName{Name: shovel.Name, Namespace: shovel.Namespace}, &fetched)).To(Succeed())
216-
return fetched.ObjectMeta.Finalizers
217-
}, 5).Should(ConsistOf("deletion.finalizers.shovels.rabbitmq.com"))
210+
It("sets the correct deletion finalizer to the object", func() {
211+
Expect(client.Create(ctx, &shovel)).To(Succeed())
212+
Eventually(func() []string {
213+
var fetched topology.Shovel
214+
Expect(client.Get(ctx, types.NamespacedName{Name: shovel.Name, Namespace: shovel.Namespace}, &fetched)).To(Succeed())
215+
return fetched.ObjectMeta.Finalizers
216+
}, 5).Should(ConsistOf("deletion.finalizers.shovels.rabbitmq.com"))
217+
})
218218
})
219219
})
220220

controllers/user_controller_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,20 +230,20 @@ var _ = Describe("UserController", func() {
230230
})
231231
})
232232
})
233-
})
234233

235-
Context("finalizer", func() {
236-
BeforeEach(func() {
237-
userName = "finalizer-test"
238-
})
234+
Context("finalizer", func() {
235+
BeforeEach(func() {
236+
userName = "finalizer-test"
237+
})
239238

240-
It("sets the correct deletion finalizer to the object", func() {
241-
Expect(client.Create(ctx, &user)).To(Succeed())
242-
Eventually(func() []string {
243-
var fetched topology.User
244-
Expect(client.Get(ctx, types.NamespacedName{Name: user.Name, Namespace: user.Namespace}, &fetched)).To(Succeed())
245-
return fetched.ObjectMeta.Finalizers
246-
}, 5).Should(ConsistOf("deletion.finalizers.users.rabbitmq.com"))
239+
It("sets the correct deletion finalizer to the object", func() {
240+
Expect(client.Create(ctx, &user)).To(Succeed())
241+
Eventually(func() []string {
242+
var fetched topology.User
243+
Expect(client.Get(ctx, types.NamespacedName{Name: user.Name, Namespace: user.Namespace}, &fetched)).To(Succeed())
244+
return fetched.ObjectMeta.Finalizers
245+
}, 5).Should(ConsistOf("deletion.finalizers.users.rabbitmq.com"))
246+
})
247247
})
248248
})
249249

0 commit comments

Comments
 (0)