add tests for the fail case

This commit is contained in:
Shreyas Goenka 2024-08-27 17:29:16 +02:00
parent a724a1129d
commit 9443ed68fe
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
13 changed files with 6319 additions and 8 deletions

View File

@ -114,6 +114,11 @@ jobs:
- name: Validate bundle schema - name: Validate bundle schema
run: | run: |
go run main.go bundle schema > schema.json go run main.go bundle schema > schema.json
for file in ./bundle/tests/schema/pass/*.yml; do for file in ./bundle/tests/schema/pass/*.yml; do
ajv -s schema.json -d $file ajv test -s schema.json -d $file --valid
done
for file in ./bundle/tests/schema/fail/*.yml; do
ajv test -s schema.json -d $file --invalid
done done

View File

@ -0,0 +1,3 @@
bundle:
# expected type is 'string'
name: 1234

View File

@ -0,0 +1,4 @@
resources:
jobs:
myjob:
format: INVALID_VALUE

View File

@ -0,0 +1,6 @@
resources:
models:
mymodel:
latest_versions:
- creation_timestamp: 123
status: INVALID_VALUE

View File

@ -0,0 +1,8 @@
resources:
jobs:
outer:
name: outer job
tasks:
- task_key: run job task 1
run_job_task:
job_id: ${invalid.reference}

View File

@ -0,0 +1,5 @@
resources:
models:
mymodel:
latest_versions:
- creation_timestamp: ${invalid.reference}

View File

@ -0,0 +1,9 @@
resources:
jobs:
foo:
name: my job
tasks:
# All tasks need to have a task_key.
- notebook_task:
notebook_path: /Users/abc/notebooks/inner
existing_cluster_id: abcd

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
resources:
jobs:
myjob:
# unknwon fields should cause schema failure.
unknown_field: "value"

View File

@ -0,0 +1,6 @@
resources:
models:
mymodel:
creation_timestamp: 123
description: "my model"
unknown: "value"

View File

@ -0,0 +1 @@
unknown: value

View File

@ -25,12 +25,7 @@ variables:
# TODO: Include enums for fields that are a part of the bundle config in the generate # TODO: Include enums for fields that are a part of the bundle config in the generate
# JSON schema. # JSON schema.
# TODO: Are all references allowed for "resources" or just ids? # TODO: No need for pattern overrides for string fields
# TODO: Ideas for fails:
# - missing required fields
# - values of the wrong type
# - enums with the wrong value
# - invalid variable references, like not the right format.
run_as: run_as:
service_principal_name: myserviceprincipal service_principal_name: myserviceprincipal

View File

@ -39,7 +39,7 @@ resources:
experiments: experiments:
myexperiment: myexperiment:
artifact_location: /dbfs/myexperiment artifact_location: /dbfs/myexperiment
last_update_time: 123 last_update_time: ${var.complexvar.key2}
lifecycle_stage: ${var.simplevar} lifecycle_stage: ${var.simplevar}
permissions: permissions:
- service_principal_name: myserviceprincipal - service_principal_name: myserviceprincipal