To protect me against these kinds of bugs, I started to write some test that checks not only the input and the output of an endpoint but test that checks data on DB too.
When I say "DB" I mean a fresh container that I turn on during every run of the tests; I avoid mock data and replies.
It will slow down a bit the development, the project I'm working on takes 3 minutes to run 1000 test cases, but when I expect some data updated there is a test for it!
But as always, you will benefit creating:
test tooling to speed up the implementation of tests
a db with a lot of test cases and edge cases you can replicate in seconds
core functionality must be always up&running and battle tests!
Thanks for sharing this situation!
To protect me against these kinds of bugs, I started to write some test that checks not only the input and the output of an endpoint but test that checks data on DB too.
When I say "DB" I mean a fresh container that I turn on during every run of the tests; I avoid mock data and replies.
It will slow down a bit the development, the project I'm working on takes 3 minutes to run 1000 test cases, but when I expect some data updated there is a test for it!
But as always, you will benefit creating:
Shameless plug: You could also use pg-mem to emulate postgres when running unit tests :) (i'm the author of this rather new lib)
this can be helpful. Thanks!