mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
add tests for skipKindsMap
This commit is contained in:
parent
2957043d95
commit
9f6965d10f
2 changed files with 44 additions and 1 deletions
4
main.go
4
main.go
|
|
@ -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
41
main_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue