Documentation ¶
Index ¶
- type TestCmd
- func (tt *TestCmd) CloseStdin()
- func (tt *TestCmd) Expect(tplsource string)
- func (tt *TestCmd) ExpectExit()
- func (tt *TestCmd) ExpectRegexp(regex string) (*regexp.Regexp, []string)
- func (tt *TestCmd) InputLine(s string) string
- func (tt *TestCmd) Interrupt()
- func (tt *TestCmd) Kill()
- func (tt *TestCmd) Run(name string, args ...string)
- func (tt *TestCmd) SetTemplateFunc(name string, fn interface{})
- func (tt *TestCmd) StderrText() string
- func (tt *TestCmd) WaitExit()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestCmd ¶
type TestCmd struct { // For total convenience, all testing methods are available. *testing.T Func template.FuncMap Data interface{} Cleanup func() // contains filtered or unexported fields }
func NewTestCmd ¶
func (*TestCmd) CloseStdin ¶
func (tt *TestCmd) CloseStdin()
func (*TestCmd) Expect ¶
Expect runs its argument as a template, then expects the child process to output the result of the template within 5s.
If the template starts with a newline, the newline is removed before matching.
func (*TestCmd) ExpectExit ¶
func (tt *TestCmd) ExpectExit()
ExpectExit expects the child process to exit within 5s without printing any additional text on stdout.
func (*TestCmd) ExpectRegexp ¶
ExpectRegexp expects the child process to output text matching the given regular expression within 5s.
Note that an arbitrary amount of output may be consumed by the regular expression. This usually means that expect cannot be used after ExpectRegexp.
func (*TestCmd) InputLine ¶
InputLine writes the given text to the childs stdin. This method can also be called from an expect template, e.g.:
neatio.expect(`Passphrase: {{.InputLine "password"}}`)
func (*TestCmd) Run ¶
Run exec's the current binary using name as argv[0] which will trigger the reexec init function for that name (e.g. "neatio-test" in cmd/neatio/run_test.go)
func (*TestCmd) SetTemplateFunc ¶
func (*TestCmd) StderrText ¶
StderrText returns any stderr output written so far. The returned text holds all log lines after ExpectExit has returned.