types

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MIT Imports: 8 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")
	ErrNoValue             = fmt.Errorf("empty parameter not found saved in values")
	ErrEmptyScenarioName   = fmt.Errorf("scenario name is empty")
)
View Source
var (
	ErrValueAlreadySet = fmt.Errorf("parameter already set in values")
	ErrEmptyValue      = fmt.Errorf("empty parameter not found in values")
)
View Source
var DefaultOpts = StepOptions{

	ExpectError: false,

	SkipSavingParamatersToJob: false,
}

Functions

This section is empty.

Types

type Job

type Job struct {
	Description     string
	Steps           []*StepWrapper
	BackgroundSteps map[string]*StepWrapper
	Scenarios       map[*StepWrapper]*Scenario
	// contains filtered or unexported fields
}

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) GetPrettyStepName

func (j *Job) GetPrettyStepName(step *StepWrapper) string

func (*Job) GetValue

func (j *Job) GetValue(stepw *StepWrapper, key string) (string, bool)

func (*Job) GetValues

func (j *Job) GetValues(stepw *StepWrapper, key string) string

GetValues is used when we want to skip saving parameters to job, but also check if the parameter exists in the scenario's or top level values

func (*Job) Run

func (j *Job) Run() error

func (*Job) SetGetValues

func (j *Job) SetGetValues(stepw *StepWrapper, key, value string) (string, error)

SetGetValues is used when we want to save parameters to job, and also check if the parameter exists in the scenario's or top level values

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) SetGet

func (j *JobValues) SetGet(key, value string) (string, error)

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

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

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.

func NewScenario

func NewScenario(name string, steps ...*StepWrapper) *Scenario

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

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

type Stop struct {
	BackgroundID string
	Step         Step
}

func (*Stop) Prevalidate

func (c *Stop) Prevalidate() error

func (*Stop) Run

func (c *Stop) Run() error

func (*Stop) Stop

func (c *Stop) Stop() error

Jump to

Keyboard shortcuts

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