more acceptance tests

This commit is contained in:
Yann Hamon 2020-10-18 14:04:23 +02:00
parent 51732e6a21
commit 9dda2ff599
3 changed files with 27 additions and 2 deletions

View file

@ -64,6 +64,12 @@
[ "$output" = "Summary: 0 resource found in 1 file - Valid: 0, Invalid: 0, Errors: 0 Skipped: 0" ]
}
@test "Pass when parsing a blank config file with a comment" {
run bin/kubeconform -summary fixtures/comment.yaml
[ "$status" -eq 0 ]
[ "$output" = "Summary: 0 resource found in 1 file - Valid: 0, Invalid: 0, Errors: 0 Skipped: 0" ]
}
@test "Fail when parsing a config with additional properties and strict set" {
run bin/kubeconform -strict -k8sversion 1.16.0 fixtures/extra_property.yaml
[ "$status" -eq 1 ]
@ -83,3 +89,19 @@
run bin/kubeconform -registry './fixtures/registry/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/test_crd.yaml
[ "$status" -eq 0 ]
}
@test "Pass when parsing a config with additional properties" {
run bin/kubeconform -summary fixtures/extra_property.yaml
[ "$status" -eq 0 ]
[ "$output" = "Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0 Skipped: 0" ]
}
@test "Pass when using a valid, preset --registry" {
run bin/kubeconform --registry kubernetesjsonschema.dev fixtures/valid.yaml
[ "$status" -eq 0 ]
}
@test "Pass when using a valid HTTP --registry" {
run bin/kubeconform --registry 'https://kubernetesjsonschema.dev/{{ .NormalizedVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/valid.yaml
[ "$status" -eq 0 ]
}

View file

@ -1,10 +1,13 @@
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nginx-ds
spec:
replicas: 2
selector:
matchLabels:
k8s-app: nginx-ds
template:
spec:
containers:

View file

@ -57,7 +57,7 @@ func (o *text) Write(filename, kind, name, version string, reserr error, skipped
_, err = fmt.Fprintf(o.w, "%s - %s %s skipped\n", filename, name, kind)
}
o.nSkipped++
case EMPTY:
case EMPTY: // sent to ensure we count the filename as parsed
}
return err