Question: In a test, with the testutil.StartCerbos...
# help
Question: In a test, with the testutil.StartCerbosServer() server, I get
request failed: rpc error: code = Internal desc = Policy check failed
. I'm sure it's a silly mistake I made, but how do I get the test server to log the actual error to further debug?
That's an interesting question. I am not sure whether it's possible. I'll try a few things and get back to you.
Turns out it's possible. You need to replace the Zap logger in your test. Here's what I did:
Copy code
logger := zaptest.NewLogger(t)
Full code listing is on this gist:
Nice one!! I'll try it out 😎 thanks 😄
So it seems that my in-memory SQLite somehow got mixed up with another in-memory sqlite database, even though that database should be isolated:
Copy code
failed to get check for [john.default]: failed to get compilation units: SQL logic error: no such table: policy_ancestor (1)
When I changed
it started working consistently. I'm not entirely sure what the difference is, but the latter is what I usually use for in-memory sqlites (as I didn't know about the first option).
should be a distinct database according to 🤔 Not sure why that didn't work. Anyway, I am glad you found a fix.
it was only a specific test failing, and I couldn't really reproduce it. I had two almost exactly identical tests where one was failing with that error and the other wasn't. I guess its one of those magical cases where you just need to do this: 🙈
nothing to see here