Hacker News new | ask | show | jobs
by direduck 209 days ago
I agree with all of this and it's what I tend to follow too.

One question, since you seem to have more experience with this approach.

> Test the API that triggers the query.

When you test the API, do you also check the state of the database?

Let's say there's an endpoint which creates an entity, and that operation involves setting a bunch of columns that aren't returned in the API.

When testing, do you check only the expected API response, or also the database state to be sure the operation was fully correct?

I currently do the latter, but this feels a bit iffy as the database internals are being leaked in an otherwise "blackbox" test.

If you learn towards the first option, how then do you verify all the unreturned database fields are correctly set?