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

rego_parse_error thrown for example tests from documentation #4849

Closed
robert-elles opened this issue Jul 6, 2022 · 3 comments · Fixed by #4852
Closed

rego_parse_error thrown for example tests from documentation #4849

robert-elles opened this issue Jul 6, 2022 · 3 comments · Fixed by #4852
Labels

Comments

@robert-elles
Copy link

Hi,

I am following the documentation for Policy Testing
and as in the documentation I created the two files with their contents: example.rego and example_test.rego.
To run the tests you are supposed to run opa test . -v in the folder where the rego files are. So I do this via docker:
docker run -v $PWD:/tests openpolicyagent/opa:0.42.0-static test /tests -v
The result output is:
/tests/example.rego:4: rego_parse_error: var cannot be used for rule name
/tests/example.rego:9: rego_parse_error: var cannot be used for rule name
/tests/example_test.rego:3: rego_parse_error: var cannot be used for rule name
/tests/example_test.rego:7: rego_parse_error: var cannot be used for rule name
/tests/example_test.rego:11: rego_parse_error: var cannot be used for rule name
/tests/example_test.rego:15: rego_parse_error: var cannot be used for rule name

So it looks like opa test isn't able to run the tests from its own documentation.
What is wrong here?

@srenatus
Copy link
Contributor

srenatus commented Jul 6, 2022

Thanks for the report! Well likely push a 0.42.1 soon, if this gets fixed quickly, it'll be part of it. Would you be up to giving it a go?

srenatus added a commit to srenatus/opa that referenced this issue Jul 6, 2022
Fixes open-policy-agent#4849.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
@srenatus
Copy link
Contributor

srenatus commented Jul 6, 2022

☝️ Taken care of it. We had been missing some future.keyword imports (and the error messages could use more hints...)

srenatus added a commit that referenced this issue Jul 6, 2022
Fixes #4849.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
@robert-elles
Copy link
Author

It works, thank you!

srenatus added a commit to srenatus/opa that referenced this issue Jul 7, 2022
ashutosh-narkar pushed a commit to ashutosh-narkar/opa that referenced this issue Jul 7, 2022
…-agent#4852)

Fixes open-policy-agent#4849.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
(cherry picked from commit f9945ee)
srenatus added a commit that referenced this issue Jul 8, 2022
Fixes #4849.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
(cherry picked from commit f9945ee)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants