testharness

package
v0.0.0-...-706a057 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLIHarness

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

CLIHarness encapsulates a single CLI session

func Create

func Create(t *testing.T) *CLIHarness

Create creates a CLI test harness that that runs CLI operations in a test directory test harness operations will propagate most environment variables to tests (with the exception of HOME, which is faked)

func (*CLIHarness) Cd

func (h *CLIHarness) Cd(s string)

Cd Changes the working directory for commands - passing "" resets this to the test directory You cannot Cd out of the test directory

func (*CLIHarness) Cleanup

func (h *CLIHarness) Cleanup()

Cleanup removes any temporary files and tries to delete any apps that (may) have been created during a test

func (*CLIHarness) CopyFiles

func (h *CLIHarness) CopyFiles(files map[string]string)

CopyFiles copies files and directories from the test source dir into the testing root directory

func (*CLIHarness) CreateFuncfile

func (h *CLIHarness) CreateFuncfile(funcName, runtime string) *CLIHarness

func (*CLIHarness) Docker

func (h *CLIHarness) Docker(args ...string) *CmdResult

func (*CLIHarness) Exec

func (h *CLIHarness) Exec(name string, args ...string) error

func (*CLIHarness) FileAppend

func (h *CLIHarness) FileAppend(file string, val string)

FileAppend appends val to an existing file

func (*CLIHarness) Fn

func (h *CLIHarness) Fn(args ...string) *CmdResult

Fn runs the Fn ClI with the specified arguments

func (*CLIHarness) FnWithInput

func (h *CLIHarness) FnWithInput(input string, args ...string) *CmdResult

FnWithInput runs the Fn ClI with an input string If a command takes more than a certain timeout then this will send a SIGQUIT to the process resulting in a stacktrace on stderr

func (*CLIHarness) GetFile

func (h *CLIHarness) GetFile(s string) string

GetFile dumps the content of a file (relative to the CWD)

func (*CLIHarness) GetYamlFile

func (h *CLIHarness) GetYamlFile(s string) common.FuncFileV20180708

func (*CLIHarness) MkDir

func (h *CLIHarness) MkDir(dir string)

MkDir creates a directory in the current cwd

func (*CLIHarness) NewAppName

func (h *CLIHarness) NewAppName() string

NewAppName creates a new, valid app name and registers it for deletion

func (*CLIHarness) NewFuncName

func (h *CLIHarness) NewFuncName(appName string) string

NewFuncName creates a valid function name and registers it for deletion

func (*CLIHarness) NewTriggerName

func (h *CLIHarness) NewTriggerName(appName, funcName string) string

NewTriggerName creates a valid trigger name and registers it for deletioneanup

func (*CLIHarness) RemoveFile

func (h *CLIHarness) RemoveFile(s string) error

func (*CLIHarness) WithEnv

func (h *CLIHarness) WithEnv(key string, value string)

WithEnv sets additional enironment variables in the test , these overlay the ambient environment

func (*CLIHarness) WithFile

func (h *CLIHarness) WithFile(rPath string, content string, perm os.FileMode)

WithFile creates a file relative to the cwd

func (*CLIHarness) WriteYamlFile

func (h *CLIHarness) WriteYamlFile(s string, ff common.FuncFileV20180708)

func (*CLIHarness) WriteYamlFileV1

func (h *CLIHarness) WriteYamlFileV1(s string, ff common.FuncFile)

type CmdResult

type CmdResult struct {
	OriginalCommand string
	Cwd             string
	ExtraEnv        []string
	Stdout          string
	Stderr          string
	Input           string
	ExitState       *os.ProcessState
	Success         bool
	History         []string
	// contains filtered or unexported fields
}

CmdResult wraps the result of a single command - this includes the diagnostic history of commands that led to this command in a given context for easier test diagnosis

func (*CmdResult) AssertFailed

func (cr *CmdResult) AssertFailed() *CmdResult

AssertFailed asserts that the command did not succeed

func (*CmdResult) AssertStderrContains

func (cr *CmdResult) AssertStderrContains(match string) *CmdResult

AssertStdoutContains asserts that the string appears somewhere in the stderr

func (*CmdResult) AssertStdoutContains

func (cr *CmdResult) AssertStdoutContains(match string) *CmdResult

AssertStdoutContains asserts that the string appears somewhere in the stdout

func (*CmdResult) AssertStdoutContainsJSON

func (cr *CmdResult) AssertStdoutContainsJSON(query []string, value interface{})

func (*CmdResult) AssertStdoutEmpty

func (cr *CmdResult) AssertStdoutEmpty()

AssertStdoutEmpty fails if there was output to stdout

func (*CmdResult) AssertStdoutMissingJSONPath

func (cr *CmdResult) AssertStdoutMissingJSONPath(query []string)

func (*CmdResult) AssertSuccess

func (cr *CmdResult) AssertSuccess() *CmdResult

AssertSuccess checks the command was success

func (*CmdResult) String

func (cr *CmdResult) String() string

Jump to

Keyboard shortcuts

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