Change:
expected: "unknown", }, } <del> for i, data := range cases { syncPodString := data.sp.String() assert.Equal(t, data.expected, syncPodString, "test[%d]", i) t.Logf("Test case [%d]", i) </del> <ins> for _, test := range tests { t.Run(test.expected, func(t *testing.T) { syncPodString := test.sp.String() assert.Equal(t, test.expected, syncPodString) }) } } func TestIsMirrorPod(t *testing.T) { tests := []struct { name     string pod      *v1.Pod expected bool }{ { name:     "mirror pod", pod:      getTestPod(configMirrorAnnotation(), nil), expected: true, }, { name:     "not a mirror pod", pod:      getTestPod(nil, nil), expected: false, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { isMirrorPod := IsMirrorPod(test.pod) assert.Equal(t, test.expected, isMirrorPod) }) } } func TestIsStaticPod(t *testing.T) { tests := []struct { name     string pod      *v1.Pod expected bool }{ { name:     "static pod with file source", pod:      getTestPod(configSourceAnnotation(FileSource), nil), expected: true, }, { name:     "static pod with http source", pod:      getTestPod(configSourceAnnotation(HTTPSource), nil), expected: true, }, { name:     "static pod with api server source", pod:      getTestPod(configSourceAnnotation(ApiserverSource), nil), expected: false, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { isStaticPod := IsStaticPod(test.pod) assert.Equal(t, test.expected, isStaticPod) }) } } func TestIsCriticalPod(t *testing.T) { tests := []struct { name     string pod      *v1.Pod expected bool }{ { name:     "critical pod with file source", pod:      getTestPod(configSourceAnnotation(FileSource), nil), expected: true, }, { name:     "critical pod with mirror annotation", pod:      getTestPod(configMirrorAnnotation(), nil), expected: true, }, { name:     "critical pod using system priority", pod:      getTestPod(nil, &systemPriority), expected: true, }, { name:     "critical pod using greater than system priority", pod:      getTestPod(nil, &systemPriorityUpper), expected: true, }, { name:     "not a critical pod with api server annotation", pod:      getTestPod(configSourceAnnotation(ApiserverSource), nil), expected: false, }, { name:     "not critical if not static, mirror or without a priority", pod:      getTestPod(nil, nil), expected: false, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { isCriticalPod := IsCriticalPod(test.pod) assert.Equal(t, test.expected, isCriticalPod) }) } } func TestPreemptable(t *testing.T) { tests := []struct { name      string preemptor *v1.Pod preemptee *v1.Pod expected  bool }{ { name:      "a critical preemptor pod preempts a non critical pod", preemptor: getTestPod(configSourceAnnotation(FileSource), nil), preemptee: getTestPod(nil, nil), expected:  true, }, { name:      "a preemptor pod with higher priority preempts a critical pod", preemptor: getTestPod(configSourceAnnotation(FileSource), &systemPriorityUpper), preemptee: getTestPod(configSourceAnnotation(FileSource), &systemPriority), expected:  true, }, { name:      "a not critical pod with higher priority preempts a critical pod", preemptor: getTestPod(configSourceAnnotation(ApiserverSource), &systemPriorityUpper), preemptee: getTestPod(configSourceAnnotation(FileSource), &systemPriority), expected:  true, }, { name:      "a critical pod with less priority do not preempts a critical pod", preemptor: getTestPod(configSourceAnnotation(FileSource), &systemPriority), preemptee: getTestPod(configSourceAnnotation(FileSource), &systemPriorityUpper), expected:  false, }, { name:      "a critical pod without priority do not preempts a critical pod without priority", preemptor: getTestPod(configSourceAnnotation(FileSource), nil), preemptee: getTestPod(configSourceAnnotation(FileSource), nil), expected:  false, }, { name:      "a critical pod with priority do not preempts a critical pod with the same priority", preemptor: getTestPod(configSourceAnnotation(FileSource), &systemPriority), preemptee: getTestPod(configSourceAnnotation(FileSource), &systemPriority), expected:  false, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { isPreemtable := Preemptable(test.preemptor, test.preemptee) assert.Equal(t, test.expected, isPreemtable) }) </ins> } } func TestIsCriticalPodBasedOnPriority(t *testing.T) { tests := []struct { <del> priority    int32 description string expected    bool </del> <ins> priority int32 name     string expected bool </ins> }{ { <del> priority:    int32(2000000001), description: "A system critical pod", expected:    true, </del> <ins> name:     "a system critical pod", priority: systemPriority, expected: true, </ins> }, { <del> priority:    int32(1000000000), description: "A non system critical pod", expected:    false, </del> <ins> name:     "a non system critical pod", priority: scheduling.HighestUserDefinablePriority, expected: false, </ins> }, } for _, test := range tests { <del> actual := IsCriticalPodBasedOnPriority(test.priority) if actual != test.expected { t.Errorf("IsCriticalPodBased on priority should have returned %v for test %v but got %v", test.expected, test.description, actual) } </del> <ins> t.Run(test.name, func(t *testing.T) { actual := IsCriticalPodBasedOnPriority(test.priority) if actual != test.expected { t.Errorf("IsCriticalPodBased on priority should have returned %v for test %v but got %v", test.expected, test.name, actual) } }) </ins> } }

Discussion:
What would you like to be : Currently, in the following public methods do not have unit test coverage: - - These methods are great candidates for adding unit test coverage. Why is this needed: Adding unit test coverage will both ensure they are working correctly and (more importantly), encode their expected behavior in the test suite. Additionally, if we want to change their behavior in the future, it'll be helpful to already have the test suites. Extra note I think this could be a great candidate for someone who is new to contributing to sig-node/k8s. I'm happy to mentor any first time contributors :) Please respond saying you'd like to work on this issue and I'll assign it to you. Please reach out to me on k8s slack (where I'm also if I can be of any assistance.
/sig node
/good-first-issue
This request has been marked as suitable for new contributors. Please ensure the request meets the requirements listed . If this request no longer meets these requirements, the label can be removed by commenting with the command. <detailsIn response to : /good-first-issue Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
Hi, I would like to work in one of these.
/assign Awesome!
Hi, I am a first time contributor and would be happy to contribute to one of these.
Hi, I want to help if still need it.