diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-02 13:08:09 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-02 13:39:09 +1100 |
commit | 4de31da4bee9c622d4c6b7152e4d918b79cb4a94 (patch) | |
tree | bd64b31772230132dcbeac5be7787c612ee0e53c /pkg/commands/os.go | |
parent | 23c51ba70841ef779e7fcef9fd2a5c717835e168 (diff) |
fix up tests
This fixes up some git and oscommand tests, and pulls some tests into commit_list_builder_test.go
I've also made the NewDummyBlah functions public so that I didn't need to duplicate them across packages
I've also given OSCommand a SetCommand() method for setting the command on the struct
I've also created a file utils.go in the test package for creating convient 'CommandSwapper's, which
basically enable you to assert a sequence of commands on the command line, and swap each one out for
a different one to actually be executed
Diffstat (limited to 'pkg/commands/os.go')
-rw-r--r-- | pkg/commands/os.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/commands/os.go b/pkg/commands/os.go index b6ef1a07f..44202e003 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -50,6 +50,12 @@ func NewOSCommand(log *logrus.Entry, config config.AppConfigurer) *OSCommand { } } +// SetCommand sets the command function used by the struct. +// To be used for testing only +func (c *OSCommand) SetCommand(cmd func(string, ...string) *exec.Cmd) { + c.command = cmd +} + // RunCommandWithOutput wrapper around commands returning their output and error func (c *OSCommand) RunCommandWithOutput(command string) (string, error) { c.Log.WithField("command", command).Info("RunCommand") |