@@ -93,6 +93,61 @@ func TestNewResourceFilter(t *testing.T) {
9393 t .Errorf ("Kinds incorrect, got: %v, want: %v." , actual , expected )
9494 }
9595
96+ actual , err = NewResourceFilter ("" , "" , []string {"rolebinding" , "serviceaccount" })
97+ expected = & ResourceFilter {
98+ ExcludedKinds : []string {"RoleBinding" , "ServiceAccount" },
99+ Kinds : []string {},
100+ Name : "" ,
101+ Label : "" ,
102+ }
103+ if err != nil || ! reflect .DeepEqual (actual , expected ) {
104+ t .Errorf ("Kinds incorrect, got: %v, want: %v." , actual , expected )
105+ }
106+
107+ }
108+
109+ func TestConvertToKinds (t * testing.T ) {
110+ tests := map [string ]struct {
111+ filter * ResourceFilter
112+ want string
113+ }{
114+ "kinds" : {
115+ filter : & ResourceFilter {
116+ ExcludedKinds : []string {},
117+ Kinds : []string {"RoleBinding" , "ServiceAccount" },
118+ Name : "" ,
119+ Label : "" ,
120+ },
121+ want : "RoleBinding,ServiceAccount" ,
122+ },
123+ "excluded kinds" : {
124+ filter : & ResourceFilter {
125+ ExcludedKinds : []string {"RoleBinding" , "ServiceAccount" },
126+ Kinds : []string {},
127+ Name : "" ,
128+ Label : "" ,
129+ },
130+ want : "Service,Route,DeploymentConfig,Deployment,BuildConfig,ImageStream,PersistentVolumeClaim,Template,ConfigMap,Secret,CronJob,Job,LimitRange,ResourceQuota,HorizontalPodAutoscaler,StatefulSet" ,
131+ },
132+ "kinds and excluded kinds" : {
133+ filter : & ResourceFilter {
134+ ExcludedKinds : []string {"RoleBinding" , "Route" },
135+ Kinds : []string {"Service" , "Route" , "DeploymentConfig" },
136+ Name : "" ,
137+ Label : "" ,
138+ },
139+ want : "Service,DeploymentConfig" ,
140+ },
141+ }
142+
143+ for name , tc := range tests {
144+ t .Run (name , func (t * testing.T ) {
145+ got := tc .filter .ConvertToKinds ()
146+ if got != tc .want {
147+ t .Errorf ("Got: %+v, want: %+v. Filter is: %+v" , got , tc .want , tc .filter )
148+ }
149+ })
150+ }
96151}
97152
98153func TestSatisfiedBy (t * testing.T ) {
0 commit comments