mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 05:59:22 +00:00
update unit tests
This commit is contained in:
parent
3a676d6790
commit
bc5131efd7
2 changed files with 11 additions and 5 deletions
|
|
@ -303,10 +303,9 @@ func downloadSchema(registries []registry.Registry, l jsonschema.SchemeURLLoader
|
|||
if err != nil {
|
||||
continue
|
||||
}
|
||||
return schema, err
|
||||
return schema, nil
|
||||
}
|
||||
|
||||
// If we get a 404, we try the next registry, but we exit if we get a real failure
|
||||
if _, notfound := err.(*loader.NotFoundError); notfound {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package validator
|
|||
import (
|
||||
"bytes"
|
||||
"github.com/santhosh-tekuri/jsonschema/v6"
|
||||
"github.com/yannh/kubeconform/pkg/loader"
|
||||
"io"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
|
@ -315,7 +316,7 @@ lastName: bar
|
|||
}`),
|
||||
false,
|
||||
false,
|
||||
Valid,
|
||||
Error,
|
||||
[]ValidationError{},
|
||||
},
|
||||
{
|
||||
|
|
@ -360,7 +361,7 @@ lastName: bar
|
|||
[]byte(`<html>error page</html>`),
|
||||
true,
|
||||
false,
|
||||
Skipped,
|
||||
Error,
|
||||
[]ValidationError{},
|
||||
},
|
||||
{
|
||||
|
|
@ -389,11 +390,17 @@ lastName: bar
|
|||
schemaDownload: downloadSchema,
|
||||
regs: []registry.Registry{
|
||||
newMockRegistry(func() (string, any, error) {
|
||||
if testCase.schemaRegistry1 == nil {
|
||||
return "", nil, loader.NewNotFoundError(nil)
|
||||
}
|
||||
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry1))
|
||||
return "", s, err
|
||||
}),
|
||||
newMockRegistry(func() (string, any, error) {
|
||||
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry1))
|
||||
if testCase.schemaRegistry2 == nil {
|
||||
return "", nil, loader.NewNotFoundError(nil)
|
||||
}
|
||||
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry2))
|
||||
return "", s, err
|
||||
}),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue