Skip to content

Commit

Permalink
Add schema flag to test (#5957)
Browse files Browse the repository at this point in the history
* test: Add --schema flag to opa test
* runner: added annotation/metadata reading for opa test

Fixes: #5923
Signed-off-by: Renato Cordeiro <renato@renatocordeiro.com>
  • Loading branch information
renatosc committed Jun 2, 2023
1 parent db3b016 commit abeed9c
Show file tree
Hide file tree
Showing 4 changed files with 273 additions and 143 deletions.
10 changes: 5 additions & 5 deletions cmd/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ package test
# METADATA
# schemas:
# - input: schema["input"]
p {
rego.metadata.rule() # presence of rego.metadata.* calls must not trigger unwanted schema evaluation
p {
rego.metadata.rule() # presence of rego.metadata.* calls must not trigger unwanted schema evaluation
input.foo == 42 # type mismatch with schema that should be ignored
}`

Expand All @@ -529,9 +529,9 @@ package test
# METADATA
# schemas:
# - input.foo: {"type": "boolean"}
p {
rego.metadata.rule() # presence of rego.metadata.* calls must not trigger unwanted schema evaluation
input.foo == 42 # type mismatch with schema that should be ignored
p {
rego.metadata.rule() # presence of rego.metadata.* calls must not trigger unwanted schema evaluation
input.foo == 42 # type mismatch with schema that should NOT be ignored since it is an inlined schema format
}`

err = testEvalWithSchemasAnnotationButNoSchemaFlag(policyWithInlinedSchema)
Expand Down

0 comments on commit abeed9c

Please sign in to comment.