ultest

package
v1.51.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands = func(clingy.Commands, ulext.External)

Commands is an alias to refer to a function that builds clingy commands.

type ExecuteOption

type ExecuteOption struct {
	// contains filtered or unexported fields
}

ExecuteOption allows one to control the environment that a command executes in.

func WithBucket

func WithBucket(name string) ExecuteOption

WithBucket ensures the bucket exists.

func WithFile

func WithFile(location string, contents ...string) ExecuteOption

WithFile sets the command to execute with a file created at the given location.

func WithFilesystem

func WithFilesystem(cb func(t *testing.T, ctx clingy.Context, fs ulfs.Filesystem)) ExecuteOption

WithFilesystem lets one do arbitrary setup on the filesystem in a callback.

func WithPendingFile

func WithPendingFile(location string) ExecuteOption

WithPendingFile sets the command to execute with a pending upload happening to the provided location.

func WithStdin

func WithStdin(stdin string) ExecuteOption

WithStdin sets the command to execute with the provided string as standard input.

type File

type File struct {
	Loc      string
	Contents string
}

File represents a file existing either locally or remotely.

type Result

type Result struct {
	Stdout  string
	Stderr  string
	Ok      bool
	Err     error
	Files   []File
	Pending []File
}

Result captures all the output of running a command for inspection.

func (Result) RequireFailure

func (r Result) RequireFailure(t *testing.T) Result

RequireFailure fails if the Result did not observe a failed execution.

func (Result) RequireFiles

func (r Result) RequireFiles(t *testing.T, files ...File) Result

RequireFiles requires that the set of files provided are all of the files that existed at the end of the execution. It assumes any passed in files with no contents contain the filename as the contents instead.

func (Result) RequireLocalFiles

func (r Result) RequireLocalFiles(t *testing.T, files ...File) Result

RequireLocalFiles requires that the set of files provided are all of the local files that existed at the end of the execution. It assumes any passed in files with no contents contain the filename as the contents instead.

func (Result) RequirePending

func (r Result) RequirePending(t *testing.T, files ...File) Result

RequirePending requires that the set of files provided are all of the files that existed as pending at the end of the execution.

func (Result) RequireRemoteFiles

func (r Result) RequireRemoteFiles(t *testing.T, files ...File) Result

RequireRemoteFiles requires that the set of files provided are all of the remote files that existed at the end of the execution. It assumes any passed in files with no contents contain the filename as the contents instead.

func (Result) RequireStderr

func (r Result) RequireStderr(t *testing.T, stderr string) Result

RequireStderr requires that the execution wrote to stderr the provided string. Blank lines are ignored and all lines are space trimmed for the comparison.

func (Result) RequireStdout

func (r Result) RequireStdout(t *testing.T, stdout string) Result

RequireStdout requires that the execution wrote to stdout the provided string. Blank lines are ignored and all lines are space trimmed for the comparison.

func (Result) RequireStdoutGlob

func (r Result) RequireStdoutGlob(t *testing.T, stdoutPattern string) Result

RequireStdoutGlob requires that the execution wrote to stdout the provided string where the * and ? characters are interpreted like shell glob patterns, except they do not match newlines. Blank lines are ignored and all lines are space trimmed for the comparison.

func (Result) RequireSuccess

func (r Result) RequireSuccess(t *testing.T)

RequireSuccess fails if the Result did not observe a successful execution.

type State

type State struct {
	// contains filtered or unexported fields
}

State represents some state and environment for a command to execute in.

func Setup

func Setup(cmds Commands, opts ...ExecuteOption) State

Setup returns some State that can be run multiple times with different command line arguments.

func (State) Fail

func (st State) Fail(t *testing.T, args ...string) Result

Fail is the same as Run followed by result.RequireFailure.

func (State) Run

func (st State) Run(t *testing.T, args ...string) Result

Run executes the command specified by the args and returns a Result.

func (State) Succeed

func (st State) Succeed(t *testing.T, args ...string) Result

Succeed is the same as Run followed by result.RequireSuccess.

func (State) With

func (st State) With(opts ...ExecuteOption) State

With appends the provided options and returns a new State.

Jump to

Keyboard shortcuts

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