trellis-cli icon indicating copy to clipboard operation
trellis-cli copied to clipboard

Wrap file IO functions

Open tangrufus opened this issue 4 years ago • 1 comments

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).

tangrufus avatar Aug 15 '19 14:08 tangrufus

Makes sense 👍 I'd have to look around since I don't know much about Go testing

swalkinshaw avatar Aug 28 '19 03:08 swalkinshaw