MCPcopy
hub / github.com/instrumenta/kubeval / TestValidateKindsToReject

Function TestValidateKindsToReject

kubeval/kubeval_test.go:205–238  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

203}
204
205func 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
240func TestDetermineSchemaURL(t *testing.T) {
241 var tests = []struct {

Callers

nothing calls this directly

Calls 2

NewDefaultConfigFunction · 0.85
ValidateWithCacheFunction · 0.85

Tested by

no test coverage detected