Don't override reference ovm in case of errors
In some Eventually loops we were overriding the reference ovm with a
fetched entity even in cases where an error was returned. These returned
ovm entities are not properly fetched an mess up the test.
@@ -139,21 +139,21 @@ var _ = Describe("OfflineVirtualMachine", func() {
updatedOVM = updatedOVM.DeepCopy()
updatedOVM.Spec.Running = true
Eventually(func() error {
- updatedOVM, err = virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Update(updatedOVM)
+ _, err := virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Update(updatedOVM)
return err
}, 300*time.Second, 1*time.Second).ShouldNot(HaveOccurred())
// Observe the VM created
Eventually(func() error {
- _, err = virtClient.VM(updatedOVM.Namespace).Get(updatedOVM.Name, v12.GetOptions{})
+ _, err := virtClient.VM(updatedOVM.Namespace).Get(updatedOVM.Name, v12.GetOptions{})
return err
}, 300*time.Second, 1*time.Second).Should(Succeed())
By("OVM has the running condition")
Eventually(func() bool {
- updatedOVM, err = virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Get(updatedOVM.Name, &v12.GetOptions{})
+ ovm, err := virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Get(updatedOVM.Name, &v12.GetOptions{})
Expect(err).ToNot(HaveOccurred())
- return updatedOVM.Status.Ready
+ return ovm.Status.Ready
}, 300*time.Second, 1*time.Second).Should(BeTrue())
return updatedOVM
@@ -169,7 +169,7 @@ var _ = Describe("OfflineVirtualMachine", func() {
updatedOVM = updatedOVM.DeepCopy()
updatedOVM.Spec.Running = false
Eventually(func() error {
- updatedOVM, err = virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Update(updatedOVM)
+ _, err := virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Update(updatedOVM)
return err
}, 300*time.Second, 1*time.Second).ShouldNot(HaveOccurred())
@@ -184,9 +184,9 @@ var _ = Describe("OfflineVirtualMachine", func() {
By("OVM has not the running condition")
Eventually(func() bool {
- updatedOVM, err = virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Get(updatedOVM.Name, &v12.GetOptions{})
+ ovm, err := virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Get(updatedOVM.Name, &v12.GetOptions{})
Expect(err).ToNot(HaveOccurred())
- return updatedOVM.Status.Ready
+ return ovm.Status.Ready
}, 300*time.Second, 1*time.Second).Should(BeFalse())
return updatedOVM
