roots / trellis-cli

A CLI to manage Trellis projects
https://roots.io/trellis/
MIT License
166 stars 25 forks source link

Wrap file IO functions #54

Open tangrufus opened 5 years ago

tangrufus commented 5 years ago

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

swalkinshaw commented 5 years ago

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