Skip to content

Commit

Permalink
Merge pull request openshift-kni#779 from openshift-kni/unit-test-upd…
Browse files Browse the repository at this point in the history
…ate-status

controller: test: don't update objects  via status()
  • Loading branch information
ffromani authored Nov 14, 2023
2 parents 96d9ec8 + 9ba4cd9 commit 9d75a29
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions controllers/numaresourcesoperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
Expect(firstLoopResult).To(Equal(reconcile.Result{RequeueAfter: time.Minute}))

// Ensure mcp1 is ready
Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(mcp1), mcp1)).ToNot(HaveOccurred())
Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(mcp1), mcp1)).To(Succeed())
mcp1.Status.Configuration.Source = []corev1.ObjectReference{
{
Name: objectnames.GetMachineConfigName(nro.Name, mcp1.Name),
Expand All @@ -172,10 +172,10 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
Status: corev1.ConditionTrue,
},
}
Expect(reconciler.Client.Status().Update(context.TODO(), mcp1))
Expect(reconciler.Client.Update(context.TODO(), mcp1)).To(Succeed())

// ensure mcp2 is ready
Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(mcp2), mcp2)).ToNot(HaveOccurred())
Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(mcp2), mcp2)).To(Succeed())
mcp2.Status.Configuration.Source = []corev1.ObjectReference{
{
Name: objectnames.GetMachineConfigName(nro.Name, mcp2.Name),
Expand All @@ -187,7 +187,7 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
Status: corev1.ConditionTrue,
},
}
Expect(reconciler.Client.Status().Update(context.TODO(), mcp2))
Expect(reconciler.Client.Update(context.TODO(), mcp2)).To(Succeed())

secondLoopResult, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key})
Expect(err).ToNot(HaveOccurred())
Expand All @@ -205,7 +205,7 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
Name: objectnames.GetComponentName(nro.Name, mcp2.Name),
Namespace: testNamespace,
}
Expect(reconciler.Client.Get(context.TODO(), mcp2DSKey, ds)).ToNot(HaveOccurred())
Expect(reconciler.Client.Get(context.TODO(), mcp2DSKey, ds)).To(Succeed())
})
When("a NodeGroup is deleted", func() {
BeforeEach(func() {
Expand Down Expand Up @@ -402,7 +402,7 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
Status: corev1.ConditionTrue,
},
}
Expect(reconciler.Client.Status().Update(context.TODO(), mcp1))
Expect(reconciler.Client.Update(context.TODO(), mcp1))

// ensure mcp2 is ready
Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(mcp2), mcp2)).ToNot(HaveOccurred())
Expand All @@ -417,7 +417,7 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
Status: corev1.ConditionTrue,
},
}
Expect(reconciler.Client.Status().Update(context.TODO(), mcp2))
Expect(reconciler.Client.Update(context.TODO(), mcp2))

key := client.ObjectKeyFromObject(nro)
secondLoopResult, err = reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key})
Expand Down Expand Up @@ -914,7 +914,7 @@ func reconcileObjects(nro *nropv1.NUMAResourcesOperator, mcp *machineconfigv1.Ma
Status: corev1.ConditionTrue,
},
}
ExpectWithOffset(1, reconciler.Client.Status().Update(context.TODO(), mcp))
ExpectWithOffset(1, reconciler.Client.Update(context.TODO(), mcp)).Should(Succeed())

var secondLoopResult reconcile.Result
secondLoopResult, err = reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key})
Expand Down

0 comments on commit 9d75a29

Please sign in to comment.