Documentation ¶
Index ¶
- func CanExecute(v cmdr.Executor)
- func HasSubcommands(v cmdr.Subcommander)
- type Terminal
- type TestOutput
- func (out TestOutput) HasLineMatching(s string) bool
- func (out TestOutput) Lines() []string
- func (out TestOutput) LinesContaining(s string) []string
- func (out TestOutput) MostSimilarLineTo(s string) (winner string, index int, goodMatch bool)
- func (out TestOutput) NumLines() int
- func (out TestOutput) ShouldHaveExactLine(s string)
- func (out TestOutput) ShouldHaveLineContaining(s string)
- func (out TestOutput) ShouldHaveNumLines(expected int)
- func (out TestOutput) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanExecute ¶
CanExecute fails the build if the thing passed does not implement the CanExecute interface.
func HasSubcommands ¶
func HasSubcommands(v cmdr.Subcommander)
HasSubcommands fails the build if the thing passed does not implement the HasSubcommands interface.
Types ¶
type Terminal ¶
Terminal is a test harness for the CLI, providing easy introspection into its inputs and outputs.
func NewTerminal ¶
NewTerminal creates a new test terminal.
func (*Terminal) PrintFailureSummary ¶
func (t *Terminal) PrintFailureSummary()
PrintFailureSummary prints the entire terminal session transcript if the failed. Otherwise, it does nothing.
func (*Terminal) RunCommand ¶
RunCommand takes a command line, turns it into args, and passes it to a CLI which is pre-populated with a fresh *cli.Sous command, OutWriter and ErrWriter, both mapped to Outputs for interrogation.
Note: This cannot cope with arguments containing spaces, even if they are surrounded by quotes. We should add this feature if we need it.
type TestOutput ¶
TestOutput allows inspection of output streams from the Terminal.
func (TestOutput) HasLineMatching ¶
func (out TestOutput) HasLineMatching(s string) bool
HasLineMatching returns true if one of the output lines exactly matches s.
func (TestOutput) Lines ¶
func (out TestOutput) Lines() []string
Lines returns a slice of strings representing lines in the output.
func (TestOutput) LinesContaining ¶
func (out TestOutput) LinesContaining(s string) []string
LinesContaining is similar to Lines, but filters lines based on if they have a substring matching s.
func (TestOutput) MostSimilarLineTo ¶
func (out TestOutput) MostSimilarLineTo(s string) ( winner string, index int, goodMatch bool)
MostSimilarLineTo returns the most similar line in the output to the given string, if any of them have a JaroWinkler score >0.1. It returns the string (or empty), the index of that line, and a bool indicating if the score was greater than 0.1
func (TestOutput) NumLines ¶
func (out TestOutput) NumLines() int
NumLines returns the number of lines in the output.
func (TestOutput) ShouldHaveExactLine ¶
func (out TestOutput) ShouldHaveExactLine(s string)
ShouldHaveExactLine fails the test if the output did not contain the line s.
func (TestOutput) ShouldHaveLineContaining ¶
func (out TestOutput) ShouldHaveLineContaining(s string)
ShouldHaveLineContaining is similar to ShouldHaveExactLine but only requires that the line contain the substring s rather then being equal to s.
func (TestOutput) ShouldHaveNumLines ¶
func (out TestOutput) ShouldHaveNumLines(expected int)
ShouldHaveNumLines fails the test if the output does not have expected lines.
func (TestOutput) String ¶
func (out TestOutput) String() string