@@ -73,7 +73,7 @@ var _ = Describe("TestFirmwareHandler", func() {
7373 }
7474
7575 DescribeTable ("Condition TypeFirmwareUpToDate should be in expected state" ,
76- func (vm * virtv2.VirtualMachine , kvvmi * virtv1.VirtualMachineInstance , expectedStatus metav1.ConditionStatus , expectedReason vmcondition.Reason , expectedExistence bool ) {
76+ func (vm * virtv2.VirtualMachine , kvvmi * virtv1.VirtualMachineInstance , expectedStatus metav1.ConditionStatus , expectedReason vmcondition.Reason ) {
7777 fakeClient , resource , vmState = setupEnvironment (vm , kvvmi )
7878 reconcile ()
7979
@@ -82,51 +82,16 @@ var _ = Describe("TestFirmwareHandler", func() {
8282 Expect (err ).NotTo (HaveOccurred ())
8383
8484 upToDate , exists := conditions .GetCondition (vmcondition .TypeFirmwareUpToDate , newVM .Status .Conditions )
85- Expect (exists ).To (Equal (expectedExistence ))
86- if exists {
87- Expect (upToDate .Status ).To (Equal (expectedStatus ))
88- Expect (upToDate .Reason ).To (Equal (expectedReason .String ()))
89- }
85+ Expect (exists ).To (BeTrue ())
86+ Expect (upToDate .Status ).To (Equal (expectedStatus ))
87+ Expect (upToDate .Reason ).To (Equal (expectedReason .String ()))
9088 },
91- Entry ("Should be up to date" , newVM (), newKVVMI (expectedImage ), metav1 .ConditionTrue , vmcondition .ReasonFirmwareUpToDate , false ),
92- Entry ("Should be up to date because kvvmi is not exists" , newVM (), nil , metav1 .ConditionTrue , vmcondition .ReasonFirmwareUpToDate , false ),
93- Entry ("Should be out of date 1" , newVM (), newKVVMI ("other-image-1" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate , true ),
94- Entry ("Should be out of date 2" , newVM (), newKVVMI ("other-image-2" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate , true ),
95- Entry ("Should be out of date 3" , newVM (), newKVVMI ("other-image-3" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate , true ),
96- Entry ("Should be out of date 4" , newVM (), newKVVMI ("other-image-4" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate , true ),
97- Entry ("Should be out of date 5" , newVM (), newKVVMI ("other-image-5" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate , true ),
98- )
99-
100- DescribeTable ("Condition TypeFirmwareUpToDate should be in the expected state considering the VM phase" ,
101- func (vm * virtv2.VirtualMachine , phase virtv2.MachinePhase , kvvmi * virtv1.VirtualMachineInstance , expectedStatus metav1.ConditionStatus , expectedExistence bool ) {
102- vm .Status .Phase = phase
103- fakeClient , resource , vmState = setupEnvironment (vm , kvvmi )
104- reconcile ()
105- newVM := & virtv2.VirtualMachine {}
106- err := fakeClient .Get (ctx , client .ObjectKeyFromObject (vm ), newVM )
107- Expect (err ).NotTo (HaveOccurred ())
108- upToDate , exists := conditions .GetCondition (vmcondition .TypeFirmwareUpToDate , newVM .Status .Conditions )
109- Expect (exists ).To (Equal (expectedExistence ))
110- if exists {
111- Expect (upToDate .Status ).To (Equal (expectedStatus ))
112- }
113- },
114- Entry ("Running phase, condition should not be set" , newVM (), virtv2 .MachineRunning , newKVVMI (expectedImage ), metav1 .ConditionUnknown , false ),
115- Entry ("Running phase, condition should be set" , newVM (), virtv2 .MachineRunning , newKVVMI ("other-image-1" ), metav1 .ConditionFalse , true ),
116-
117- Entry ("Migrating phase, condition should not be set" , newVM (), virtv2 .MachineMigrating , newKVVMI (expectedImage ), metav1 .ConditionUnknown , false ),
118- Entry ("Migrating phase, condition should be set" , newVM (), virtv2 .MachineMigrating , newKVVMI ("other-image-1" ), metav1 .ConditionFalse , true ),
119-
120- Entry ("Stopping phase, condition should not be set" , newVM (), virtv2 .MachineStopping , newKVVMI (expectedImage ), metav1 .ConditionUnknown , false ),
121- Entry ("Stopping phase, condition should be set" , newVM (), virtv2 .MachineStopping , newKVVMI ("other-image-1" ), metav1 .ConditionFalse , true ),
122-
123- Entry ("Pending phase, condition should not be set" , newVM (), virtv2 .MachinePending , newKVVMI (expectedImage ), metav1 .ConditionUnknown , false ),
124- Entry ("Pending phase, condition should not be set" , newVM (), virtv2 .MachinePending , newKVVMI ("other-image-1" ), metav1 .ConditionUnknown , false ),
125-
126- Entry ("Starting phase, condition should not be set" , newVM (), virtv2 .MachineStarting , newKVVMI (expectedImage ), metav1 .ConditionUnknown , false ),
127- Entry ("Starting phase, condition should not be set" , newVM (), virtv2 .MachineStarting , newKVVMI ("other-image-1" ), metav1 .ConditionUnknown , false ),
128-
129- Entry ("Stopped phase, condition should not be set" , newVM (), virtv2 .MachineStopped , newKVVMI (expectedImage ), metav1 .ConditionUnknown , false ),
130- Entry ("Stopped phase, condition should not be set" , newVM (), virtv2 .MachineStopped , newKVVMI ("other-image-1" ), metav1 .ConditionUnknown , false ),
89+ Entry ("Should be up to date" , newVM (), newKVVMI (expectedImage ), metav1 .ConditionTrue , vmcondition .ReasonFirmwareUpToDate ),
90+ Entry ("Should be up to date because kvvmi is not exists" , newVM (), nil , metav1 .ConditionTrue , vmcondition .ReasonFirmwareUpToDate ),
91+ Entry ("Should be out of date 1" , newVM (), newKVVMI ("other-image-1" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate ),
92+ Entry ("Should be out of date 2" , newVM (), newKVVMI ("other-image-2" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate ),
93+ Entry ("Should be out of date 3" , newVM (), newKVVMI ("other-image-3" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate ),
94+ Entry ("Should be out of date 4" , newVM (), newKVVMI ("other-image-4" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate ),
95+ Entry ("Should be out of date 5" , newVM (), newKVVMI ("other-image-5" ), metav1 .ConditionFalse , vmcondition .ReasonFirmwareOutOfDate ),
13196 )
13297})
0 commit comments