Documentation
¶
Overview ¶
Package testrun contains helper functionality for executing CLI tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestRun ¶
type TestRun struct {
T testing.TB
Context context.Context
Run *run.Run
Out *bytes.Buffer
ErrOut *bytes.Buffer
// contains filtered or unexported fields
}
TestRun is a helper for testing sq commands.
func New ¶
New returns a new run instance for testing sq commands. If from is non-nil, its config is used. This allows sequential commands to use the same config.
func (*TestRun) Add ¶
Add adds srcs to tr.Run.Config.Collection. If the collection does not already have an active source, the first element of srcs is used as the active source.
REVISIT: Why not use *source.Source instead of the value?
func (*TestRun) Exec ¶
Exec executes the sq command specified by args. If the first element of args is not "sq", that value is prepended to the args for execution. This method may only be invoked once. The backing Run will also be closed. If an error occurs on the client side during execution, that error is returned. Either tr.Out or tr.ErrOut will be filled, according to what the CLI outputs.
func (*TestRun) Hush ¶
Hush suppresses the printing of output collected in out and errOut to t.Log. Collection to true for tests that output excessive content, binary files, etc.
func (*TestRun) MustReadCSV ¶
MustReadCSV reads CSV from tr.Out and returns all records, failing the testing on any problem. Obviously the Exec call should have specified "--csv".