From c5b9debe56dc6576cbf453690ce8a588f295cfc9 Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Mon, 15 Dec 2025 12:57:19 +0100 Subject: [PATCH] refactor(TestPodAntiAffinity): ensure p1 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 14a360370..c270ff703 100644 --- a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go +++ b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go @@ -65,7 +65,10 @@ func buildTestPodForNode1(name string, apply func(*v1.Pod)) *v1.Pod { func TestPodAntiAffinity(t *testing.T) { - p1 := buildTestPodForNode1("p1", nil) + p1 := buildTestPodForNode1("p1", func(pod *v1.Pod) { + test.SetNormalOwnerRef(pod) + test.SetPodAntiAffinity(pod, "foo", "bar") + }) p2 := buildTestPodForNode1("p2", nil) p3 := buildTestPodForNode1("p3", nil) p4 := buildTestPodForNode1("p4", nil) @@ -89,7 +92,6 @@ func TestPodAntiAffinity(t *testing.T) { p7.Labels = map[string]string{"foo1": "bar1"} p11.Labels = map[string]string{"foo": "bar"} nonEvictablePod.Labels = map[string]string{"foo": "bar"} - test.SetNormalOwnerRef(p1) test.SetNormalOwnerRef(p2) test.SetNormalOwnerRef(p3) test.SetNormalOwnerRef(p4) @@ -101,7 +103,6 @@ func TestPodAntiAffinity(t *testing.T) { test.SetNormalOwnerRef(p11) // set pod anti affinity - test.SetPodAntiAffinity(p1, "foo", "bar") test.SetPodAntiAffinity(p3, "foo", "bar") test.SetPodAntiAffinity(p4, "foo", "bar") test.SetPodAntiAffinity(p5, "foo1", "bar1")