Documentation ¶
Index ¶
- type CLIHarness
- func (h *CLIHarness) Cd(s string)
- func (h *CLIHarness) Cleanup()
- func (h *CLIHarness) CopyFiles(files map[string]string)
- func (h *CLIHarness) CreateFuncfile(funcName, runtime string) *CLIHarness
- func (h *CLIHarness) Docker(args ...string) *CmdResult
- func (h *CLIHarness) Exec(name string, args ...string) error
- func (h *CLIHarness) FileAppend(file string, val string)
- func (h *CLIHarness) Fn(args ...string) *CmdResult
- func (h *CLIHarness) FnWithInput(input string, args ...string) *CmdResult
- func (h *CLIHarness) GetFile(s string) string
- func (h *CLIHarness) GetYamlFile(s string) common.FuncFileV20180708
- func (h *CLIHarness) MkDir(dir string)
- func (h *CLIHarness) NewAppName() string
- func (h *CLIHarness) NewFuncName(appName string) string
- func (h *CLIHarness) NewTriggerName(appName, funcName string) string
- func (h *CLIHarness) RemoveFile(s string) error
- func (h *CLIHarness) WithEnv(key string, value string)
- func (h *CLIHarness) WithFile(rPath string, content string, perm os.FileMode)
- func (h *CLIHarness) WriteYamlFile(s string, ff common.FuncFileV20180708)
- func (h *CLIHarness) WriteYamlFileV1(s string, ff common.FuncFile)
- type CmdResult
- func (cr *CmdResult) AssertFailed() *CmdResult
- func (cr *CmdResult) AssertStderrContains(match string) *CmdResult
- func (cr *CmdResult) AssertStdoutContains(match string) *CmdResult
- func (cr *CmdResult) AssertStdoutContainsJSON(query []string, value interface{})
- func (cr *CmdResult) AssertStdoutEmpty()
- func (cr *CmdResult) AssertStdoutMissingJSONPath(query []string)
- func (cr *CmdResult) AssertSuccess() *CmdResult
- func (cr *CmdResult) String() string
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) 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 ¶
AssertFailed asserts that the command did not succeed
func (*CmdResult) AssertStderrContains ¶
AssertStdoutContains asserts that the string appears somewhere in the stderr
func (*CmdResult) AssertStdoutContains ¶
AssertStdoutContains asserts that the string appears somewhere in the stdout
func (*CmdResult) AssertStdoutContainsJSON ¶
func (*CmdResult) AssertStdoutEmpty ¶
func (cr *CmdResult) AssertStdoutEmpty()
AssertStdoutEmpty fails if there was output to stdout
func (*CmdResult) AssertStdoutMissingJSONPath ¶
func (*CmdResult) AssertSuccess ¶
AssertSuccess checks the command was success