Open tangrufus opened 5 years ago
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
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).
go test -short
mockExecCommand
Makes sense 👍 I'd have to look around since I don't know much about Go testing
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 (likemockExecCommand
).