types

package
v1.15.22 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyDescription    = fmt.Errorf("job description is empty")
	ErrNonNilError         = fmt.Errorf("expected error to be non-nil")
	ErrNilError            = fmt.Errorf("expected error to be nil")
	ErrMissingParameter    = fmt.Errorf("missing parameter")
	ErrParameterAlreadySet = fmt.Errorf("parameter already set")
	ErrOrphanSteps         = fmt.Errorf("background steps with no corresponding stop")
	ErrCannotStopStep      = fmt.Errorf("cannot stop step")
	ErrMissingBackroundID  = fmt.Errorf("missing background id")
)
View Source
var DefaultOpts = StepOptions{

	ExpectError: false,

	SkipSavingParamatersToJob: false,
}

Functions

This section is empty.

Types

type Job

type Job struct {
	Values          *JobValues
	Description     string
	Steps           []*StepWrapper
	BackgroundSteps map[string]*StepWrapper
}

A Job is a logical grouping of steps, options and values

func NewJob

func NewJob(description string) *Job

func (*Job) AddScenario

func (j *Job) AddScenario(scenario *Scenario)

func (*Job) AddStep

func (j *Job) AddStep(step Step, opts *StepOptions)

func (*Job) Run

func (j *Job) Run() error

func (*Job) Validate

func (j *Job) Validate() error

type JobValues

type JobValues struct {
	RWLock sync.RWMutex
	// contains filtered or unexported fields
}

func (*JobValues) Contains

func (j *JobValues) Contains(key string) bool

func (*JobValues) Get

func (j *JobValues) Get(key string) string

func (*JobValues) New

func (j *JobValues) New() *JobValues

func (*JobValues) Set

func (j *JobValues) Set(key, value string)

type Runner

type Runner struct {
	Job *Job
	// contains filtered or unexported fields
}

A wrapper around a job, so that internal job components don't require things like *testing.T and can be reused elsewhere

func NewRunner

func NewRunner(t *testing.T, job *Job) *Runner

func (*Runner) Run

func (r *Runner) Run()

type Scenario added in v1.5.21

type Scenario struct {
	Steps []*StepWrapper
}

A Scenario is a logical grouping of steps, used to describe a scenario such as "test drop metrics" which will require port forwarding, exec'ing, scraping, etc.

type Sleep

type Sleep struct {
	Duration time.Duration
}

func (*Sleep) Prevalidate

func (c *Sleep) Prevalidate() error

func (*Sleep) Run

func (c *Sleep) Run() error

func (*Sleep) Stop added in v1.5.21

func (c *Sleep) Stop() error

type Step

type Step interface {
	// Useful when wanting to do parameter checking, for example
	// if a parameter length is known to be required less than 80 characters,
	// do this here so we don't find out later on when we run the step
	// when possible, try to avoid making external calls, this should be fast and simple
	Prevalidate() error

	// Primary step where test logic is executed
	// Returning an error will cause the test to fail
	Run() error

	// Require for background steps
	Stop() error
}

type StepOptions

type StepOptions struct {
	ExpectError bool

	// Generally set this to false when you want to reuse
	// a step, but you don't want to save the parameters
	// ex: Sleep for 15 seconds, then Sleep for 10 seconds,
	// you don't want to save the parameters
	SkipSavingParamatersToJob bool

	// Will save this step to the job's steps
	// and then later on when Stop is called with job name,
	// it will call Stop() on the step
	RunInBackgroundWithID string
}

type StepWrapper

type StepWrapper struct {
	Step Step
	Opts *StepOptions
}

A StepWrapper is a coupling of a step and it's options

type Stop added in v1.5.21

type Stop struct {
	BackgroundID string
	Step         Step
}

func (*Stop) Prevalidate added in v1.5.21

func (c *Stop) Prevalidate() error

func (*Stop) Run added in v1.5.21

func (c *Stop) Run() error

func (*Stop) Stop added in v1.5.21

func (c *Stop) Stop() error

Jump to

Keyboard shortcuts

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