Example:
- owned a legacy system that deployed software to production
- there were "deployment windows" for different applications
- the "is now time to deploy app X?" logic was a giant rat's nest of if/then statements
- AND it used datetime.now() in the function
- that meant you had to wait for the window to actually hit to see if any changes worked
- changed the function to be can_deploy(current_time = datetime.now()) so you could pass in a time
- meant we could add unit tests
- changes to the logic went from taking two people 45 minutes hand tracing to <30 seconds
I tell this story whenever people say "I don't have time for unit tests!". I think they mean "I don't have time to write an entire suite of unit tests" which might be fair. But there is ALWAYS time to write a couple key tests.