Documentation
¶
Index ¶
- func GetArgs(ctx context.Context, cmd harness.Command, namespace string, ...) (*exec.Cmd, error)
- func IsSubset(expected, actual interface{}) error
- func RunAssertCommands(ctx context.Context, logger Logger, namespace string, ...) ([]*exec.Cmd, error)
- func RunCommand(ctx context.Context, namespace string, cmd harness.Command, cwd string, ...) (*exec.Cmd, error)
- func RunCommands(ctx context.Context, logger Logger, namespace string, ...) ([]*exec.Cmd, error)
- func RunTests(testName string, testToRun string, parallelism int, testFunc func(*testing.T))
- type DockerClient
- type Logger
- type SubsetError
- type TestLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetArgs ¶
func GetArgs(ctx context.Context, cmd harness.Command, namespace string, envMap map[string]string) (*exec.Cmd, error)
GetArgs parses a command line string into its arguments and appends a namespace if it is not already set.
func IsSubset ¶
func IsSubset(expected, actual interface{}) error
IsSubset checks to see if `expected` is a subset of `actual`. A "subset" is an object that is equivalent to the other object, but where map keys found in actual that are not defined in expected are ignored.
func RunAssertCommands ¶ added in v0.9.0
func RunAssertCommands(ctx context.Context, logger Logger, namespace string, commands []harness.TestAssertCommand, workdir string, timeout int, kubeconfigOverride string) ([]*exec.Cmd, error)
RunAssertCommands runs a set of commands specified as TestAssertCommand
func RunCommand ¶
func RunCommand(ctx context.Context, namespace string, cmd harness.Command, cwd string, stdout io.Writer, stderr io.Writer, logger Logger, timeout int, kubeconfigOverride string) (*exec.Cmd, error)
RunCommand runs a command with args. args gets split on spaces (respecting quoted strings). if the command is run in the background a reference to the process is returned for later cleanup
func RunCommands ¶
func RunCommands(ctx context.Context, logger Logger, namespace string, commands []harness.Command, workdir string, timeout int, kubeconfigOverride string) ([]*exec.Cmd, error)
RunCommands runs a set of commands, returning any errors. If any (non-background) command fails, the following commands are skipped commands running in the background are returned
func RunTests ¶
RunTests runs a Go test method without requiring the Go compiler. This does not currently support test caching. If testToRun is set to a non-empty string, it is passed as a `-run` argument to the go test harness. If paralellism is set, it limits the number of concurrently running tests.
Types ¶
type DockerClient ¶
type DockerClient interface { NegotiateAPIVersion(context.Context) VolumeCreate(context.Context, volumetypes.CreateOptions) (volumetypes.Volume, error) ImageSave(context.Context, []string) (io.ReadCloser, error) }
DockerClient is a wrapper interface for the Docker library to support unit testing.
type Logger ¶
type Logger interface { Log(args ...interface{}) Logf(format string, args ...interface{}) WithPrefix(string) Logger Write(p []byte) (n int, err error) Flush() }
Logger is an interface used by the KUTTL test operator to provide logging of tests.
type SubsetError ¶
type SubsetError struct {
// contains filtered or unexported fields
}
SubsetError is an error type used by IsSubset for tracking the path in the struct.
func (*SubsetError) AppendPath ¶
func (e *SubsetError) AppendPath(key string)
AppendPath appends key to the existing struct path. For example, in struct member `a.Key1.Key2`, the path would be ["Key1", "Key2"]
func (*SubsetError) Error ¶
func (e *SubsetError) Error() string
Error implements the error interface.
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger implements the Logger interface to be compatible with the go test operator's output buffering (without this, the use of Parallel tests combined with subtests causes test output to be mixed).
func NewTestLogger ¶
func NewTestLogger(test *testing.T, prefix string) *TestLogger
NewTestLogger creates a new test logger.
func (*TestLogger) Flush ¶ added in v0.2.1
func (t *TestLogger) Flush()
func (*TestLogger) Log ¶
func (t *TestLogger) Log(args ...interface{})
Log logs the provided arguments with the logger's prefix. See testing.Log for more details.
func (*TestLogger) Logf ¶
func (t *TestLogger) Logf(format string, args ...interface{})
Logf logs the provided arguments with the logger's prefix. See testing.Logf for more details.
func (*TestLogger) WithPrefix ¶
func (t *TestLogger) WithPrefix(prefix string) Logger
WithPrefix returns a new TestLogger with the provided prefix appended to the current prefix.