From da55c779f2f23b8bee33ecd3c6a663c0855f67be Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Mon, 15 Dec 2025 13:18:50 +0100 Subject: [PATCH] refactor(TestPodAntiAffinity): ensure p2 is created only through apply argument --- .../pod_antiaffinity_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go index c270ff703..12c5f24a9 100644 --- a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go +++ b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go @@ -69,7 +69,10 @@ func TestPodAntiAffinity(t *testing.T) { test.SetNormalOwnerRef(pod) test.SetPodAntiAffinity(pod, "foo", "bar") }) - p2 := buildTestPodForNode1("p2", nil) + p2 := buildTestPodForNode1("p2", func(pod *v1.Pod) { + test.SetNormalOwnerRef(pod) + pod.Labels = map[string]string{"foo": "bar"} + }) p3 := buildTestPodForNode1("p3", nil) p4 := buildTestPodForNode1("p4", nil) p5 := buildTestPodForNode1("p5", nil) @@ -86,13 +89,11 @@ func TestPodAntiAffinity(t *testing.T) { nonEvictablePod := buildTestPodForNode1("non-evict", func(pod *v1.Pod) { pod.Spec.Priority = &criticalPriority }) - p2.Labels = map[string]string{"foo": "bar"} p5.Labels = map[string]string{"foo": "bar"} p6.Labels = map[string]string{"foo": "bar"} p7.Labels = map[string]string{"foo1": "bar1"} p11.Labels = map[string]string{"foo": "bar"} nonEvictablePod.Labels = map[string]string{"foo": "bar"} - test.SetNormalOwnerRef(p2) test.SetNormalOwnerRef(p3) test.SetNormalOwnerRef(p4) test.SetNormalOwnerRef(p5)