Code Cleanup, vmi_configuration_test.go: remove redundant condition
remove `if len(x) > 0` before `for range x`
`for-range` will do nothing if the collection is empty.
No need to check it before.
@@ -1142,14 +1142,12 @@ var _ = Describe("[sig-compute]Configurations", func() {
vmi, err := virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Get(hugepagesVmi.Name, &metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
- if len(vmi.Status.Conditions) > 0 {
for _, cond := range vmi.Status.Conditions {
if cond.Type == v1.VirtualMachineInstanceConditionType(kubev1.PodScheduled) && cond.Status == kubev1.ConditionFalse {
vmiCondition = cond
return true
}
}
- }
return false
}, 30*time.Second, time.Second).Should(BeTrue())
Expect(vmiCondition.Message).To(ContainSubstring("Insufficient hugepages-3Mi"))
@@ -2234,14 +2232,12 @@ var _ = Describe("[sig-compute]Configurations", func() {
vmi, err := virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Get(vmi.Name, &metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
- if len(vmi.Status.Conditions) > 0 {
for _, cond := range vmi.Status.Conditions {
if cond.Type == v1.VirtualMachineInstanceConditionType(v1.VirtualMachineInstanceSynchronized) && cond.Status == kubev1.ConditionFalse {
vmiCondition = cond
return true
}
}
- }
return false
}, 120*time.Second, time.Second).Should(BeTrue())
Expect(vmiCondition.Message).To(ContainSubstring("Invalid PCI address " + wrongPciAddress))
