Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteTests ¶
ExecuteTests takes in the testing.T and a list of integration tests to run.
func FindBinaryPath ¶
FindBinaryPath executes a reverse walk to find the ecl binary on the parent path.
Types ¶
type Args ¶
type Args struct { // Arguments to pass to the test binary Args []string // Args that represent the configuration. This field is appended to Args. // This needn't be used, it is a nice way to keep your command configuration // sepparate from the command arguments. Config []string // Uses the strings as keys to load the stored value from `teststorage.Storage` // the parameter is ignored if not found in the result map, and passed as the key DynamicArgs []string // list of commands to be run when an interactive session is open Interactive []string }
Args represent the test arguments.
type Assertion ¶
type Assertion struct { // Asserts the Output Output []string // Asserts the errors Errors []string // Asserts dynamically stored values (Key-based). Dynamic []string // When set to true, it ensures that all the items in Output and Errors are // are found. Strict bool // Regex Patterns to match. Pattern []string }
Assertion represent the test assertions after the test has run.
type Assertions ¶
type Assertions struct { // WantErr ensures that a exit code > 0 is returned after the command's // execution. WantErr bool // CanError causes the test not to fail in case the command returns an error. // This is useful for commands which can return an error depending on external // factors, useful when the output is still asserted but an error might be returned. CanError bool // CanErrorWithMessage contains a slice of known failure states where the test // will not fail, if there's a partial match of any of the messages. CanErrorWithMessage []string // Must ensures that the defined assertions are found. Must Assertion // Not ensures that the defined assertions are not found. Not Assertion }
Assertions defines a series of Must and MustNot assertions after a test is run.
func (Assertions) Ensure ¶
func (a Assertions) Ensure(stdout, stderr *bytes.Buffer, err error, storage teststorage.Storage, args string) error
Ensure verifies that the assertions match, otherwise it throws an error via t.Error
type Callback ¶
type Callback func(output []byte, storageKey string, storage teststorage.Storage) error
Callback is a function which receives the output in the form of []byte and a string which is a storage key for the value. The function will normally decode the output to cleanly store it in the key. In case any errors occur, an error will be returned.
type Test ¶
type Test struct { // The test name Name string // The relative or full path of the binary to use for the test. Binary string // When set, the Binary name will be used to reverse find the binary on the // path. It will traverse the current path backwards until it finds a file // This is meant to be used with binary artifacts that have been built and // can be found within the project directory boundaries. FindBinary bool // Arguments to pass to the binary. Args Args // the following list of strings must be found in the specified // channels, stdout, stderr. Assert Assertions // callbacks to be run after the test is finished, the stdout output // is passed as the first argument and the key is used, see decode... // functions for callback examples Callbacks TestCallback // optionally set how much time the test should wait before run WaitBeforeRun time.Duration // If set, the test will be run in parallel instead of sequentially. Parallel bool }
Test defines a test
type TestCallback ¶
TestCallback defines a relationship between a test function and its key.
func NewTestCallback ¶
func NewTestCallback(s string, t Callback) TestCallback
NewTestCallback creates a new callback
func (TestCallback) Run ¶
func (tc TestCallback) Run(out []byte, storage teststorage.Storage) error
Run calls each stored callback and stores the output of the command on the passed storage via the prefixed key in the callback map.