Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support raising builtin errors in the test runner #6490

Merged

Conversation

jalseth
Copy link
Member

@jalseth jalseth commented Dec 16, 2023

It can be useful to know if Rego unit tests fail due to logic errors, or if a builtin raised an error, such as parsing JSON input that was typo'd.

Fixes #6489.

Copy link

netlify bot commented Dec 16, 2023

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit d160fd4
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/6580990a68dd660008be1d2e
😎 Deploy Preview https://deploy-preview-6490--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

It can be useful to know if Rego unit tests fail due to logic errors, or
if a builtin raised an error, such as parsing JSON input that was typo'd.

Signed-off-by: James Alseth <james@jalseth.me>
if len(builtinErrors) == 1 {
tr.Error = &builtinErrors[0]
} else {
tr.Error = fmt.Errorf("%v", builtinErrors)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We could add a test case to exercise this path but seems fine.

Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ashutosh-narkar ashutosh-narkar merged commit 6d26f98 into open-policy-agent:main Dec 18, 2023
24 checks passed
@jalseth jalseth deleted the tester-builtin-errors branch December 20, 2023 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support raising builtin errors for test runner
2 participants