scripts: Add tests for options

This commit is contained in:
Maxime Brunet 2021-12-12 11:34:23 -08:00
parent 67a73a9315
commit 30528c5671
No known key found for this signature in database
GPG key ID: 757B11B65F872567
3 changed files with 7115 additions and 0 deletions

View file

@ -2,6 +2,7 @@
setup() {
rm -f prometheus_v1.json
rm -f prometheus-monitoring-v1.json
}
@test "Should generate expected prometheus resource" {
@ -19,3 +20,19 @@ setup() {
run diff prometheus_v1.json ./fixtures/prometheus_v1-expected.json
[ "$status" -eq 0 ]
}
@test "Should output filename in {kind}-{group}-{version} format" {
FILENAME_FORMAT='{kind}-{group}-{version}' run ./openapi2jsonschema.py fixtures/prometheus-operator-0prometheusCustomResourceDefinition.yaml
[ "$status" -eq 0 ]
[ "$output" = "JSON schema written to prometheus-monitoring-v1.json" ]
run diff prometheus-monitoring-v1.json ./fixtures/prometheus_v1-expected.json
[ "$status" -eq 0 ]
}
@test "Should set 'additionalProperties: false' at the root" {
DENY_ROOT_ADDITIONAL_PROPERTIES='true' run ./openapi2jsonschema.py fixtures/prometheus-operator-0prometheusCustomResourceDefinition.yaml
[ "$status" -eq 0 ]
[ "$output" = "JSON schema written to prometheus_v1.json" ]
run diff prometheus_v1.json ./fixtures/prometheus_v1-denyRootAdditionalProperties.json
[ "$status" -eq 0 ]
}

File diff suppressed because it is too large Load diff