mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-18 01:49:53 +00:00
more unit tests
This commit is contained in:
parent
0d2da2d582
commit
cdcacb080d
2 changed files with 149 additions and 0 deletions
46
pkg/registry/kubernetesjsonschema_test.go
Normal file
46
pkg/registry/kubernetesjsonschema_test.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package registry
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSchemaURL(t *testing.T) {
|
||||
for i, testCase := range []struct {
|
||||
resourceKind, resourceAPIVersion, k8sVersion, expected string
|
||||
strict bool
|
||||
}{
|
||||
{
|
||||
"Deployment",
|
||||
"apps/v1",
|
||||
"1.16.0",
|
||||
"https://kubernetesjsonschema.dev/v1.16.0-standalone-strict/deployment-apps-v1.json",
|
||||
true,
|
||||
},
|
||||
{
|
||||
"Deployment",
|
||||
"apps/v1",
|
||||
"1.16.0",
|
||||
"https://kubernetesjsonschema.dev/v1.16.0-standalone/deployment-apps-v1.json",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"Service",
|
||||
"v1",
|
||||
"1.18.0",
|
||||
"https://kubernetesjsonschema.dev/v1.18.0-standalone/service-v1.json",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"Service",
|
||||
"v1",
|
||||
"master",
|
||||
"https://kubernetesjsonschema.dev/master-standalone/service-v1.json",
|
||||
false,
|
||||
},
|
||||
} {
|
||||
reg := NewKubernetesRegistry(testCase.strict)
|
||||
if got := reg.schemaURL(testCase.resourceKind, testCase.resourceAPIVersion, testCase.k8sVersion); got != testCase.expected {
|
||||
t.Errorf("%d - got %s, expected %s", i+1, got, testCase.expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue