Accompanies this article: Unit-Testing-Exec-Command-In-Golang
Package funshell
contains the ShellCommand
function which is being tested.
ShellCommand
just kicks off the shell command echo 'fun!'
.
The main
function in main.go
just calls this, catches errors and then prints out anything that was output to stdout.
Package funshell_test
runs some simple unit tests against ShellCommand
.
Run the program with go run main.go
.
Run the tests with go test ./..
.