Search code examples
open-policy-agentrego

OPA unit-test failing, How to output response variable?


Newbie to OPA, I am writing OPA unit test case.

test_valid_type {
  response = evaluate with
             input as valid_type
  response == "approved"
}

it's failing response == "approved". I want to see the output of response variable, how do i output it?


Solution

  • Try the trace method provided by OPA for debugging. https://www.openpolicyagent.org/docs/latest/policy-reference/#debugging

    This will let you print the output. In your example you can add trace(response) which will print the response output.