e2e

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanOutput

func CleanOutput(stdOutput string) string

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

func GetCurrentServiceRevision(t *testing.T, serviceName string) string

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 GetKnativeServiceUrl

func GetKnativeServiceUrl(t *testing.T, functionName string) string

func GetRegistry

func GetRegistry() string

GetRegistry returns registry

func GetRuntime

func GetRuntime() string

GetRuntime returns the runtime that should be tested.

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

type TestShellCmdResult struct {
	Stdout string
	Stderr string
	Error  error
}

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`

Jump to

Keyboard shortcuts

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