Fabric: How can I unit test my fabfile?
django, fabric, python
Solution
run your Fabfile task in a Docker instance
use docker diff to verify that the right files were changed by the Fabfile.
This is still quite a bit of work, but it allows testing without excessive Fabfile modifications.
Problem
In the previous project I was working on, our fabfile got out of control. While the rest of our project was well-tested, we didn't write a single test for our fabfile. Refactoring was scary, and we weren't confident a fabric command would work how we expected until we ran the command. I'm starting a new project, and I'd like to make sure our fabfile is well-tested from the beginning. Obey the Testing Goat has a great article discussing some possible strategies, yet it has more questions than answers. Using fabtest is a possibility, although it seems to be dead. Has anyone successfully unit tested their fabfile? If so, how?