Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TestModeEnvVar = "GO_TEST_MODE" CallbackTestMode = "CALLBACK" CallbackFunctionName = "GO_CALLBACK_FUNCTION_NAME" )
Functions ¶
func RegisterCallback ¶
Call this method to register your callback function from your init() method. This is required before creating a TestRunner that uses your function.
Types ¶
type TestRunner ¶
type TestRunner struct {
// contains filtered or unexported fields
}
func NewTestRunner ¶
func NewTestRunner(callback func(cmd string, args ...string) (exitCode int)) (*TestRunner, error)
TestRunner makes it easy to mock out shell commands. It will start a new program that calls into the callback function supplied when creating TestRunner.
To use TestRunner from your test, you must do the following:
- In your test file's init() method call RegisterCallback with the same callback function you passed into TestRunner
- Copy the TestMain below and insert it into your test file: func TestMain(m *testing.M) { cmd_runner.TestMain(m) }
func NewTestRunnerFailOnErr ¶
func (*TestRunner) CombinedOutput ¶
func (runner *TestRunner) CombinedOutput(cmd string, args ...string) (string, error)
Click to show internal directories.
Click to hide internal directories.