From 03d517555d5c1c010fc5bb9c4f9d788cc6c1c82d Mon Sep 17 00:00:00 2001 From: Omer Aplatony Date: Tue, 3 Dec 2024 13:14:06 +0200 Subject: [PATCH] VPA: add error checking to pods eviction test Signed-off-by: Omer Aplatony --- .../updater/eviction/pods_eviction_restriction_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vertical-pod-autoscaler/pkg/updater/eviction/pods_eviction_restriction_test.go b/vertical-pod-autoscaler/pkg/updater/eviction/pods_eviction_restriction_test.go index 7f93c33df371..6685c144cc46 100644 --- a/vertical-pod-autoscaler/pkg/updater/eviction/pods_eviction_restriction_test.go +++ b/vertical-pod-autoscaler/pkg/updater/eviction/pods_eviction_restriction_test.go @@ -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", @@ -609,6 +610,7 @@ func TestEvictEmitEvent(t *testing.T) { evictionSuccess: true, }, }, + errorExpected: false, }, { name: "Pod that can not be evicted", @@ -623,6 +625,7 @@ func TestEvictEmitEvent(t *testing.T) { evictionSuccess: false, }, }, + errorExpected: true, }, } @@ -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)