trellis-cli
trellis-cli copied to clipboard
Wrap file IO functions
- [x] I've read the guidelines for Contributing to Roots Projects
- [x] This request isn't a duplicate of an existing request
- [x] This is not a personal support request that should be posted on the Roots Discourse community
Summary
Wrap file IO functions, something like:
https://github.com/roots/trellis-cli/blob/9900ff93b4e4e93f2a73bdae7eeec318b40c8aaf/cmd/main.go#L7
https://github.com/roots/trellis-cli/blob/9900ff93b4e4e93f2a73bdae7eeec318b40c8aaf/cmd/cmd_test.go#L19-L25
Motivation
Currently, tests that perform file IO might fail because files might not exist. Leaving them only testable in integration test.
Wrapping file IO functions makes uniting tests (go test -short
) possible (like mockExecCommand
).
Makes sense 👍 I'd have to look around since I don't know much about Go testing