# README
go-command
exec.Command
wrapper for better testing.
How does it work?
const dummyCommand = "dummy"
type Foo struct {
Commander command.Interface
}
func (f Foo) Run() error {
_, err := f.Commander.Output(dummyCommand)
if err != nil {
return err
}
return nil
}
func TestCommand_Output(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
m := mocks.NewMockInterface(ctrl)
m.EXPECT().Output(dummyCommand).Return([]byte{}, nil)
foo := Foo{
Commander: m,
}
err := foo.Run()
assert.Equal(t, err, nil)
}
# Packages
Package mocks is a generated GoMock package.
# Interfaces
go:generate mockgen -destination=mocks/commander_mock.go -package=mocks github.com/omegion/go-command Interface Interface is an interface for Command.