Skip to content

Commit

Permalink
VPA: add error checking to pods eviction test
Browse files Browse the repository at this point in the history
Signed-off-by: Omer Aplatony <[email protected]>
  • Loading branch information
omerap12 committed Dec 3, 2024
1 parent cd58f3f commit 03d5175
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ func TestEvictEmitEvent(t *testing.T) {
evictionTolerance float64
vpa *vpa_types.VerticalPodAutoscaler
pods []podWithExpectations
errorExpected bool
}{
{
name: "Pods that can be evicted",
Expand All @@ -609,6 +610,7 @@ func TestEvictEmitEvent(t *testing.T) {
evictionSuccess: true,
},
},
errorExpected: false,
},
{
name: "Pod that can not be evicted",
Expand All @@ -623,6 +625,7 @@ func TestEvictEmitEvent(t *testing.T) {
evictionSuccess: false,
},
},
errorExpected: true,
},
}

Expand All @@ -642,7 +645,12 @@ func TestEvictEmitEvent(t *testing.T) {
mockRecorder.On("Event", mock.Anything, apiv1.EventTypeNormal, "EvictedByVPA", mock.Anything).Return()
mockRecorder.On("Event", mock.Anything, apiv1.EventTypeNormal, "EvictedPod", mock.Anything).Return()

_ = eviction.Evict(p.pod, testCase.vpa, mockRecorder)
errGot := eviction.Evict(p.pod, testCase.vpa, mockRecorder)
if testCase.errorExpected {
assert.Error(t, errGot)
} else {
assert.NoError(t, errGot)
}

if p.canEvict {
mockRecorder.AssertNumberOfCalls(t, "Event", 2)
Expand Down

0 comments on commit 03d5175

Please sign in to comment.