tests

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanExecute

func CanExecute(v cmdr.Executor)

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

type Terminal struct {
	*cmdr.CLI
	Stdout, Stderr, Combined TestOutput
	History                  []string
	T                        *testing.T
}

Terminal is a test harness for the CLI, providing easy introspection into its inputs and outputs.

func NewTerminal

func NewTerminal(t *testing.T, root cmdr.Command) *Terminal

func (*Terminal) PrintFailureSummary

func (t *Terminal) PrintFailureSummary()

func (*Terminal) RunCommand

func (t *Terminal) RunCommand(commandline string)

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.

func (*Terminal) Summary

func (t *Terminal) Summary() string

Summary prints a summary of the session.

type TestOutput

type TestOutput struct {
	Name   string
	Buffer *bytes.Buffer
	T      *testing.T
}

Output allows inspection of output streams from the Terminal.

func (TestOutput) HasLineMatching

func (out TestOutput) HasLineMatching(s string) bool

func (TestOutput) Lines

func (out TestOutput) Lines() []string

func (TestOutput) LinesContaining

func (out TestOutput) LinesContaining(s string) []string

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

func (TestOutput) ShouldHaveExactLine

func (out TestOutput) ShouldHaveExactLine(s string)

func (TestOutput) ShouldHaveLineContaining

func (out TestOutput) ShouldHaveLineContaining(s string)

func (TestOutput) ShouldHaveNumLines

func (out TestOutput) ShouldHaveNumLines(expected int)

func (TestOutput) String

func (out TestOutput) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL