Documentation
¶
Overview ¶
Package cmdrs has various built-in implementations of Commander for use in tests and examples.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteString ¶
WriteString writes to the Writer, discarding the returned byte count. The error is always non-nil if the returned count != len(s), so the count isn't interesting if all you care about is error existence. Handy in test assertions, e.g. assert.NoError(t, WriteString(w, "data"))
Types ¶
type HoardingCommander ¶
type HoardingCommander struct {
KondoCommander
// contains filtered or unexported fields
}
HoardingCommander keeps everything sent into Write. Handy for tests, debugging etc.
func NewHoardingCommander ¶
func NewHoardingCommander(c string) *HoardingCommander
NewHoardingCommander returns a new instance of HoardingCommander.
func (*HoardingCommander) Reset ¶
func (c *HoardingCommander) Reset()
Reset clears the internal buffer.
func (*HoardingCommander) Result ¶
func (c *HoardingCommander) Result() string
Result returns the buffer contents as a string.
type KondoCommander ¶
type KondoCommander struct {
Command string
}
KondoCommander quietly discards everything sent to Write and always reports Success true. Use this when you just want to run a command and don't care about the command's output.
func (*KondoCommander) String ¶
func (c *KondoCommander) String() string
String returns the command string.
func (*KondoCommander) Success ¶
func (c *KondoCommander) Success() bool
Success always returns true.
type PrintingCommander ¶
type PrintingCommander struct {
KondoCommander
// contains filtered or unexported fields
}
PrintingCommander echos everything to stdout. Only useful for examples, tests, debugging, etc.
func NewPrintingCommander ¶
func NewPrintingCommander(c string, o io.Writer) *PrintingCommander
NewPrintingCommander returns a new instance of PrintingCommander.
type SimpleSentinelCommander ¶
type SimpleSentinelCommander struct {
Command string // the command, e.g. "echo Rumplestilskin"
Value string // the sentinel value to look for, e.g. "Rumplestilskin".
// contains filtered or unexported fields
}
SimpleSentinelCommander is a Commander that asserts Success if it sees Value anywhere in the output of Command.
func (*SimpleSentinelCommander) Match ¶
func (c *SimpleSentinelCommander) Match() string
Match returns the winning line.
func (*SimpleSentinelCommander) Reset ¶
func (c *SimpleSentinelCommander) Reset()
Reset resets everything.
func (*SimpleSentinelCommander) String ¶
func (c *SimpleSentinelCommander) String() string
func (*SimpleSentinelCommander) Success ¶
func (c *SimpleSentinelCommander) Success() bool
Success returns true if Value found.