Change:
"testing" "github.com/stretchr/testify/assert" <del> "github.com/stretchr/testify/require" </del> v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" <ins> "k8s.io/kubernetes/pkg/apis/scheduling" </ins> ) <ins> var ( systemPriority      = int32(scheduling.SystemCriticalPriority) systemPriorityUpper = systemPriority + 1000 ) // getTestPod generates a new instance of an empty test Pod func getTestPod(annotations map[string]string, podPriority *int32) *v1.Pod { pod := v1.Pod{ TypeMeta: metav1.TypeMeta{ Kind:       "Pod", APIVersion: "v1", }, ObjectMeta: metav1.ObjectMeta{ Name:      "foo", Namespace: "default", }, } // Set pod Priority in Spec if exists if podPriority != nil { pod.Spec = v1.PodSpec{ Priority: podPriority, } } // Set annotations if exists if annotations != nil { pod.Annotations = annotations } return &pod } func configSourceAnnotation(source string) map[string]string { return map[string]string{ConfigSourceAnnotationKey: source} } func configMirrorAnnotation() map[string]string { return map[string]string{ConfigMirrorAnnotationKey: "true"} } </ins> func TestGetValidatedSources(t *testing.T) { <del> // Empty. sources, err := GetValidatedSources([]string{""}) require.NoError(t, err) require.Len(t, sources, 0) // Success. sources, err = GetValidatedSources([]string{FileSource, ApiserverSource}) require.NoError(t, err) require.Len(t, sources, 2) // All. sources, err = GetValidatedSources([]string{AllSource}) require.NoError(t, err) require.Len(t, sources, 3) // Unknown source. _, err = GetValidatedSources([]string{"taco"}) require.Error(t, err) </del> <ins> tests := []struct { name        string sources     []string errExpected bool sourcesLen  int }{ { name:        "empty source", sources:     []string{""}, errExpected: false, sourcesLen:  0, }, { name:        "file and apiserver source", sources:     []string{FileSource, ApiserverSource}, errExpected: false, sourcesLen:  2, }, { name:        "all source", sources:     []string{AllSource}, errExpected: false, sourcesLen:  3, }, { name:        "unknown source", sources:     []string{"unknown"}, errExpected: true, sourcesLen:  0, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { sources, err := GetValidatedSources(test.sources) if test.errExpected { assert.Error(t, err) } else { assert.NoError(t, err) } assert.Len(t, sources, test.sourcesLen) }) } </ins> } func TestGetPodSource(t *testing.T) { <del> cases := []struct { pod         v1.Pod </del> <ins> tests := []struct { name        string pod         *v1.Pod </ins> expected    string errExpected bool }{ { <del> pod:         v1.Pod{}, </del> <ins> name:        "cannot get pod source", pod:         getTestPod(nil, nil), </ins> expected:    "", errExpected: true, }, { <del> pod: v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kubernetes.io/config.source": "host-ipc-sources", }, }, }, </del> <ins> name:        "valid annotation returns the source", pod:         getTestPod(configSourceAnnotation("host-ipc-sources"), nil), </ins> expected:    "host-ipc-sources", errExpected: false, }, } <del> for i, data := range cases { source, err := GetPodSource(&data.pod) if data.errExpected { assert.Error(t, err) } else { assert.NoError(t, err) } assert.Equal(t, data.expected, source, "test[%d]", i) t.Logf("Test case [%d]", i) </del> <ins> for _, test := range tests { t.Run(test.name, func(t *testing.T) { source, err := GetPodSource(test.pod) if test.errExpected { assert.Error(t, err) } else { assert.NoError(t, err) } assert.Equal(t, test.expected, source) }) </ins> } } func TestString(t *testing.T) { <del> cases := []struct { </del> <ins> tests := []struct { </ins> sp       SyncPodType expected string }{

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.