mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-21 10:57:01 +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 {
|
if err != nil {
|
||||||
continue
|
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 {
|
if _, notfound := err.(*loader.NotFoundError); notfound {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package validator
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/santhosh-tekuri/jsonschema/v6"
|
"github.com/santhosh-tekuri/jsonschema/v6"
|
||||||
|
"github.com/yannh/kubeconform/pkg/loader"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -315,7 +316,7 @@ lastName: bar
|
||||||
}`),
|
}`),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Valid,
|
Error,
|
||||||
[]ValidationError{},
|
[]ValidationError{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -360,7 +361,7 @@ lastName: bar
|
||||||
[]byte(`<html>error page</html>`),
|
[]byte(`<html>error page</html>`),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Skipped,
|
Error,
|
||||||
[]ValidationError{},
|
[]ValidationError{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -389,11 +390,17 @@ lastName: bar
|
||||||
schemaDownload: downloadSchema,
|
schemaDownload: downloadSchema,
|
||||||
regs: []registry.Registry{
|
regs: []registry.Registry{
|
||||||
newMockRegistry(func() (string, any, error) {
|
newMockRegistry(func() (string, any, error) {
|
||||||
|
if testCase.schemaRegistry1 == nil {
|
||||||
|
return "", nil, loader.NewNotFoundError(nil)
|
||||||
|
}
|
||||||
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry1))
|
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry1))
|
||||||
return "", s, err
|
return "", s, err
|
||||||
}),
|
}),
|
||||||
newMockRegistry(func() (string, any, error) {
|
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
|
return "", s, err
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue