From 3ebffe5a86ac038dd7ec055ec9776cf5038574b2 Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Sun, 14 Dec 2025 14:20:48 +0100 Subject: [PATCH] refactor(TestFindDuplicatePods): inline p13 pod creation --- .../removeduplicates/removeduplicates_test.go | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/pkg/framework/plugins/removeduplicates/removeduplicates_test.go b/pkg/framework/plugins/removeduplicates/removeduplicates_test.go index e29b4de32..c126314b2 100644 --- a/pkg/framework/plugins/removeduplicates/removeduplicates_test.go +++ b/pkg/framework/plugins/removeduplicates/removeduplicates_test.go @@ -99,12 +99,6 @@ func TestFindDuplicatePods(t *testing.T) { // Three Pods in the "test" Namespace, bound to same ReplicaSet. 2 should be evicted. // Same owners, but different images // Multiple containers - p13 := buildTestPodWithRSOwnerRefWithNamespaceForNode1("p13", "different-images", func(pod *v1.Pod) { - pod.Spec.Containers = append(pod.Spec.Containers, v1.Container{ - Name: "foo", - Image: "foo", - }) - }) // ### Pods Evictable Based On Node Fit ### p15 := buildTestPodWithRSOwnerRefWithNamespaceForNode1("p15", "node-fit", func(pod *v1.Pod) { pod.Spec.NodeSelector = map[string]string{ @@ -272,8 +266,15 @@ func TestFindDuplicatePods(t *testing.T) { expectedEvictedPodCount: 0, }, { - description: "Pods with multiple containers should not match themselves", - pods: []*v1.Pod{p13}, + description: "Pods with multiple containers should not match themselves", + pods: []*v1.Pod{ + buildTestPodWithRSOwnerRefWithNamespaceForNode1("p13", "different-images", func(pod *v1.Pod) { + pod.Spec.Containers = append(pod.Spec.Containers, v1.Container{ + Name: "foo", + Image: "foo", + }) + }), + }, nodes: []*v1.Node{node1, node2}, expectedEvictedPodCount: 0, }, @@ -282,7 +283,14 @@ func TestFindDuplicatePods(t *testing.T) { pods: []*v1.Pod{ buildTestPodWithRSOwnerRefWithNamespaceForNode1("p11", "different-images", func(pod *v1.Pod) { pod.Spec.Containers[0].Image = "foo" - }), p13}, + }), + buildTestPodWithRSOwnerRefWithNamespaceForNode1("p13", "different-images", func(pod *v1.Pod) { + pod.Spec.Containers = append(pod.Spec.Containers, v1.Container{ + Name: "foo", + Image: "foo", + }) + }), + }, nodes: []*v1.Node{node1, node2}, expectedEvictedPodCount: 0, },