testing

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(name string, testSetup SetupFn)

func AddMultiStage

func AddMultiStage(name string, testSetup MultiStageSetupFn)

func AddScenario

func AddScenario(scenario ScenarioInfo, testSetup SetupFn)

func GetScenarioNames

func GetScenarioNames() []string

Types

type ActiveScenario

type ActiveScenario struct {
	Stages     []Stage
	TeardownFn TeardownFn

	Name string

	AutoTeardownAfter time.Duration
	// contains filtered or unexported fields
}

func NewActiveScenarios

func NewActiveScenarios(name string, env map[string]string, fn MultiStageSetupFn, autoTeardownIdleDuration time.Duration) (*ActiveScenario, error)

func (*ActiveScenario) AutoTeardown

func (s *ActiveScenario) AutoTeardown() *CancellableTimer

func (*ActiveScenario) RecordDroppedIteration

func (s *ActiveScenario) RecordDroppedIteration()

func (*ActiveScenario) Run

func (s *ActiveScenario) Run(metric metrics.MetricType, stage, vu, iter string, f func(t *T)) error

func (*ActiveScenario) SetAutoTeardown

func (s *ActiveScenario) SetAutoTeardown(timer *CancellableTimer)

type CancellableTimer

type CancellableTimer struct {
	C chan bool
	// contains filtered or unexported fields
}

func NewCancellableTimer

func NewCancellableTimer(d time.Duration) *CancellableTimer

func (*CancellableTimer) Cancel

func (c *CancellableTimer) Cancel() bool

Cancel makes all the waiters receive false

func (*CancellableTimer) Reset

func (c *CancellableTimer) Reset(duration time.Duration)

type MultiStageSetupFn

type MultiStageSetupFn func(t *T) ([]Stage, TeardownFn)

func GetScenario

func GetScenario(scenarioName string) MultiStageSetupFn

type RunFn

type RunFn func(t *T)

RunFn performs a single iteration of the test. It my be used for asserting results or failing the test.

type ScenarioInfo

type ScenarioInfo struct {
	Name        string
	Description string
	Parameters  []ScenarioParameter
}

type ScenarioParameter

type ScenarioParameter struct {
	Name        string
	Description string
	Default     string
}

type SetupFn

type SetupFn func(t *T) (RunFn, TeardownFn)

SetupFn performs any setup required to run a scenario. It returns a RunFn to be invoked for every iteration of the tests and a TeardownFn to clear down any resources after all iterations complete

func WithNoSetup

func WithNoSetup(fn func(t *T)) SetupFn

type Stage

type Stage struct {
	Name  string
	RunFn RunFn
}

type T

type T struct {
	// Identifier of the user for the test
	VirtualUser string
	// Iteration number, "setup" or "teardown"
	Iteration string
	// Logger with user and iteration tags
	Log *log.Logger

	Require     *require.Assertions
	Environment map[string]string
	Scenario    string
	// contains filtered or unexported fields
}

func NewT

func NewT(env map[string]string, vu, iter string, scenarioName string) *T

func (*T) Errorf

func (t *T) Errorf(format string, args ...interface{})

func (*T) Fail

func (t *T) Fail()

func (*T) FailNow

func (t *T) FailNow()

func (*T) HasFailed

func (t *T) HasFailed() bool

func (*T) Time

func (t *T) Time(stageName string, f func())

Time records a metric for the duration of the given function

type TeardownFn

type TeardownFn RunFn

TeardownFn clears down any resources from a test run after all iterations complete.

type TeardownRegistry

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

func NewTeardownRegistry

func NewTeardownRegistry(t *T) TeardownRegistry

func (*TeardownRegistry) RegisterForTeardown

func (c *TeardownRegistry) RegisterForTeardown(fn func())

func (*TeardownRegistry) RegisterForTeardownT

func (c *TeardownRegistry) RegisterForTeardownT(fn func(t *T))

func (*TeardownRegistry) Teardown

func (c *TeardownRegistry) Teardown(t *T)

Jump to

Keyboard shortcuts

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