(t *testing.T)
| 171 | } |
| 172 | |
| 173 | func TestValidateMultipleResourcesWithErrors(t *testing.T) { |
| 174 | var tests = []string{ |
| 175 | "multi_invalid_resources.yaml", |
| 176 | } |
| 177 | for _, test := range tests { |
| 178 | config := NewDefaultConfig() |
| 179 | filePath, _ := filepath.Abs("../fixtures/" + test) |
| 180 | fileContents, _ := ioutil.ReadFile(filePath) |
| 181 | config.ExitOnError = true |
| 182 | config.FileName = test |
| 183 | _, err := Validate(fileContents, config) |
| 184 | if err == nil { |
| 185 | t.Errorf("Validate should not pass when testing invalid configuration in " + test) |
| 186 | } else if merr, ok := err.(*multierror.Error); ok { |
| 187 | if len(merr.Errors) != 1 { |
| 188 | t.Errorf("Validate should encounter exactly 1 error when testing invalid configuration in " + test + " with ExitOnError=true") |
| 189 | } |
| 190 | } |
| 191 | config.ExitOnError = false |
| 192 | _, err = Validate(fileContents, config) |
| 193 | if err == nil { |
| 194 | t.Errorf("Validate should not pass when testing invalid configuration in " + test) |
| 195 | } else if merr, ok := err.(*multierror.Error); ok { |
| 196 | if len(merr.Errors) != 5 { |
| 197 | t.Errorf("Validate should encounter exactly 5 errors when testing invalid configuration in " + test) |
| 198 | } |
| 199 | } else if !ok { |
| 200 | t.Errorf("Validate should encounter exactly 5 errors when testing invalid configuration in " + test) |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | func TestValidateKindsToReject(t *testing.T) { |
| 206 | var tests = []struct { |
nothing calls this directly
no test coverage detected