(t *testing.T)
| 203 | } |
| 204 | |
| 205 | func TestValidateKindsToReject(t *testing.T) { |
| 206 | var tests = []struct { |
| 207 | Name string |
| 208 | KindsToReject []string |
| 209 | Fixture string |
| 210 | Pass bool |
| 211 | }{ |
| 212 | { |
| 213 | Name: "allow_all", |
| 214 | KindsToReject: []string{}, |
| 215 | Fixture: "valid.yaml", |
| 216 | Pass: true, |
| 217 | }, |
| 218 | { |
| 219 | Name: "reject_one", |
| 220 | KindsToReject: []string{"ReplicationController"}, |
| 221 | Fixture: "valid.yaml", |
| 222 | Pass: false, |
| 223 | }, |
| 224 | } |
| 225 | schemaCache := make(map[string]*gojsonschema.Schema, 0) |
| 226 | |
| 227 | for _, test := range tests { |
| 228 | filePath, _ := filepath.Abs("../fixtures/" + test.Fixture) |
| 229 | fileContents, _ := ioutil.ReadFile(filePath) |
| 230 | config := NewDefaultConfig() |
| 231 | config.FileName = test.Fixture |
| 232 | config.KindsToReject = test.KindsToReject |
| 233 | _, err := ValidateWithCache(fileContents, schemaCache, config) |
| 234 | if err != nil && test.Pass == true { |
| 235 | t.Errorf("Validate should pass when testing valid configuration in " + test.Name) |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | func TestDetermineSchemaURL(t *testing.T) { |
| 241 | var tests = []struct { |
nothing calls this directly
no test coverage detected