Documentation
¶
Index ¶
- func CleanOutput(stdOutput string) string
- func GetCurrentServiceRevision(t *testing.T, serviceName string) string
- func GetFuncBinaryPath() string
- func GetKnativeServiceUrl(t *testing.T, functionName string) string
- func GetRegistry() string
- func GetRuntime() string
- func IsUseKnFunc() bool
- func NewRevisionCheck(t *testing.T, previousRevision string, serviceName string) (newRevision string)
- func ReadyCheck(t *testing.T, knFunc *TestShellCmdRunner, project FunctionTestProject)
- func RetrieveKnativeServiceResource(t *testing.T, serviceName string) *unstructured.Unstructured
- type FunctionTestProject
- type TestShellCmdResult
- type TestShellCmdRunner
- type TestShellInteractiveCmdRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanOutput ¶
CleanOutput Some commands, such as deploy command, spans spinner chars and cursor shifts at output which are captured and merged regular output messages. This functions is meant to remove these chars in order to facilitate tests assertions and data extraction from output
func GetCurrentServiceRevision ¶
GetCurrentServiceRevision retrieves current revision name for the deployed function
func GetFuncBinaryPath ¶
func GetFuncBinaryPath() string
GetFuncBinaryPath should return the Path of 'func' binary under test
func IsUseKnFunc ¶
func IsUseKnFunc() bool
IsUseKnFunc indicates that tests should be run against "kn func" instead of "func" binary
func NewRevisionCheck ¶
func NewRevisionCheck(t *testing.T, previousRevision string, serviceName string) (newRevision string)
NewRevisionCheck waits for a new revision to report as ready
func ReadyCheck ¶
func ReadyCheck(t *testing.T, knFunc *TestShellCmdRunner, project FunctionTestProject)
ReadyCheck waits deployed function to report as ready.
func RetrieveKnativeServiceResource ¶
func RetrieveKnativeServiceResource(t *testing.T, serviceName string) *unstructured.Unstructured
RetrieveKnativeServiceResource wraps the logic to query knative serving resources in current namespace
Types ¶
type FunctionTestProject ¶
type FunctionTestProject struct {
// Function Name. Example "func-node-http"
FunctionName string
// Project location on filesystem.
// Example /tmp/func-node-http | %USERPROFILE%\AddData\Local\Temp\func-node-http
ProjectPath string
// Function Runtime. Example "node"
Runtime string
// Function Template. Example "http"
Template string
// Git Location of a Remote Repository used to pull the template
RemoteRepository string
// Indicates which builder should be uses (i.e: pack|s2i)
Builder string
// Indicates function is already built
IsBuilt bool
// Indicates function is already deployed
IsDeployed bool
// Indicates new revision deployed (custom template)
IsNewRevision bool
// Function URL
FunctionURL string
}
FunctionTestProject structure to represent a function testing project location stored on filesystem
func NewFunctionTestProject ¶
func NewFunctionTestProject(t *testing.T, runtime string, template string) FunctionTestProject
NewFunctionTestProject initiates a project with derived function name an project path
func (FunctionTestProject) CreateProjectFolder ¶
func (f FunctionTestProject) CreateProjectFolder() error
CreateProjectFolder creates and empty folder for the project location.
func (FunctionTestProject) ExistsProjectFolder ¶
func (f FunctionTestProject) ExistsProjectFolder() bool
ExistsProjectFolder determine the project folder exists or not
func (FunctionTestProject) RemoveProjectFolder ¶
func (f FunctionTestProject) RemoveProjectFolder() error
RemoveProjectFolder removes existing project folder
type TestShellCmdResult ¶
TestShellCmdResult stored command result
func (TestShellCmdResult) Dump ¶
func (r TestShellCmdResult) Dump(t *testing.T)
type TestShellCmdRunner ¶
type TestShellCmdRunner struct {
// binary to invoke
// Example: "func", "kn", "kubectl", "/usr/bin/sh"
Binary string
// Binary args to append before actual args. Examples:
// when 'kn' binary binaryArgs should be ["func"]
BinaryArgs []string
// Run commands from Dir
SourceDir string
// Indicates shell should dump command line args during execution
ShouldDumpCmdLine bool
// Indicates shell should dump
ShouldDumpOnSuccess bool
// Environment variable to be used with the command
Env []string
// Boolean
T *testing.T
}
func NewKnFuncShellCli ¶
func NewKnFuncShellCli(t *testing.T) *TestShellCmdRunner
func (*TestShellCmdRunner) Exec ¶
func (f *TestShellCmdRunner) Exec(args ...string) TestShellCmdResult
Exec invokes go exec library and runs a shell command combining the binary args with args from method signature
func (*TestShellCmdRunner) FromDir ¶
func (f *TestShellCmdRunner) FromDir(dir string) *TestShellCmdRunner
func (*TestShellCmdRunner) WithEnv ¶
func (f *TestShellCmdRunner) WithEnv(envKey string, envValue string) *TestShellCmdRunner
type TestShellInteractiveCmdRunner ¶
type TestShellInteractiveCmdRunner struct {
TestShell *TestShellCmdRunner
T *testing.T
// contains filtered or unexported fields
}
func NewTestShellInteractiveCmdRunner ¶
func NewTestShellInteractiveCmdRunner(t *testing.T) *TestShellInteractiveCmdRunner
func (*TestShellInteractiveCmdRunner) PrepareRun ¶
func (f *TestShellInteractiveCmdRunner) PrepareRun(funcCommand ...string) func(args ...string) TestShellCmdResult
Prepare creates a go function used to start kn func (binary) that requires user interaction such as `func config command`