Any ideas how you test the SQL using this approach?
I jest. I don't like mocking database methods, they don't give me much confidence. I test the SQL against Postgres in a Docker container.
With a real DB it's not exactly easy to inject "ERROR: deadlock" at every single step.