add tests for skipKindsMap

This commit is contained in:
Yann Hamon 2020-06-01 16:47:35 +02:00
parent 2957043d95
commit 9f6965d10f
2 changed files with 44 additions and 1 deletions

View file

@ -141,7 +141,9 @@ func skipKindsMap(skipKindsCSV string) map[string]bool {
splitKinds := strings.Split(skipKindsCSV, ",")
skipKinds := map[string]bool{}
for _, kind := range splitKinds {
skipKinds[kind] = true
if len(kind) > 0 {
skipKinds[kind] = true
}
}
return skipKinds
}

41
main_test.go Normal file
View file

@ -0,0 +1,41 @@
package main
import (
"reflect"
"testing"
)
func TestSkipKindMaps(t *testing.T) {
for _, testCase := range []struct {
name string
csvSkipKinds string
expect map[string]bool
} {
{
"nothing to skip",
"",
map[string]bool {},
},
{
"a single kind to skip",
"somekind",
map[string]bool {
"somekind": true,
},
},
{
"multiple kinds to skip",
"somekind,anotherkind,yetsomeotherkind",
map[string]bool {
"somekind": true,
"anotherkind": true,
"yetsomeotherkind": true,
},
},
} {
got := skipKindsMap(testCase.csvSkipKinds)
if !reflect.DeepEqual(got, testCase.expect) {
t.Errorf("%s - got %+v, expected %+v", testCase.name, got, testCase.expect)
}
}
}