package status import ( "testing" "github.com/stretchr/testify/assert" ) func TestIsNotReported(t *testing.T) { testCases := []struct { title string kind string notReportedElem map[string]bool expected bool }{ { title: "Case 1 - Empty Map", kind: "Shipment", notReportedElem: make(map[string]bool), expected: false, }, { title: "Case 2 - Nil Map", kind: "Shipment", notReportedElem: nil, expected: false, }, { title: "Case 3", kind: "Shipment", notReportedElem: map[string]bool{ "Shipment": true, "Kustomization": true, "Bucket": false, }, expected: true, }, { title: "Case 4", kind: "Shipment", notReportedElem: map[string]bool{ "Shipment": false, "Kustomization": true, "Bucket": false, }, expected: false, }, } for _, testCase := range testCases { t.Run(testCase.title, func(t *testing.T) { actual := IsNotReported(testCase.kind, testCase.notReportedElem) assert.Equal(t, testCase.expected, actual) }) } } func TestMergeErrorMessages(t *testing.T) { testCases := []struct { title string errors []string expected string }{ { title: "Case 1 - nil", errors: nil, expected: "", }, { title: "Case 2 - empty array", errors: make([]string, 0), expected: "", }, { title: "Case 3 - length is 2", errors: []string{"hello", "world"}, expected: "hello and world", }, { title: "Case 4 - length is 3", errors: []string{"hello", "beautiful", "world"}, expected: "hello, beautiful, and world", }, } for _, testCase := range testCases { t.Run(testCase.title, func(t *testing.T) { actual := MergeErrorMessages(testCase.errors) assert.Equal(t, testCase.expected, actual) }) } }