"return a closure of what to do given a cursor into the database"
Some people would insist that the closure is a mock, but otherwise this is correct, using closures in this way does help isolate one's tests.
Some people would insist that the closure is a mock, but otherwise this is correct, using closures in this way does help isolate one's tests.
This is one of the big benefits of FP and pure functions really. I'm sure there would be practicalities that get in the way of doing this cleanly for all code, but it can go a surprisingly long way. The idea is to write a completely pure core and restrict input/output to be through a few small and obviously correct functions.