scenarios

package
v0.0.0-...-1f8a15b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnmatchedStepArgumentNumber = errors.New("func received more arguments than expected")
	ErrCannotConvert               = errors.New("cannot convert argument")
	ErrUnsupportedArgumentType     = errors.New("unsupported argument type")
)
View Source
var ErrUndefined = fmt.Errorf("step is undefined")

ErrUndefined is returned in case if step definition was not found

View Source
var TimeNowFunc = func() time.Time {
	return time.Now()
}

Functions

func ContextValues

func ContextValues(ctx context.Context) []context.Context

func JoinContexts

func JoinContexts(ctx context.Context, others ...context.Context) context.Context

func MustRegisterStepHandlers

func MustRegisterStepHandlers(handlers ...stepHandler)

func Param

func Param[P any](ctx context.Context, name string) (P, bool)

func RegisterStepHandlers

func RegisterStepHandlers(handlers ...stepHandler) error

func Run

func Run(ctx context.Context, scenarios ...*Scenario) error

func StepHandler

func StepHandler(handler interface{}, matchExpressions ...string) stepHandler

Types

type AfterScenarioHook

type AfterScenarioHook func(context.Context, *Scenario, error) (context.Context, error)

type AfterStepHook

type AfterStepHook func(context.Context, *Step, StepStatus, error) (context.Context, error)

type BeforeScenarioHook

type BeforeScenarioHook func(context.Context, *Scenario) (context.Context, error)

type BeforeStepHook

type BeforeStepHook func(context.Context, *Step) (context.Context, error)

type CompoundContext

type CompoundContext struct {
	context.Context
	// contains filtered or unexported fields
}

func (*CompoundContext) Err

func (join *CompoundContext) Err() error

func (*CompoundContext) Value

func (join *CompoundContext) Value(key interface{}) interface{}

type Context

type Context interface {
	devnet.Context
	WithParam(name string, value interface{}) Context
}

func WithParam

func WithParam(ctx context.Context, name string, value interface{}) Context

type Options

type Options struct {
	Concurrency int
}

type Params

type Params map[string]interface{}

type Scenario

type Scenario struct {
	Context     devnet.Context `json:"-"`
	Id          string         `json:"id"`
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Steps       []*Step        `json:"steps"`
}

type ScenarioError

type ScenarioError struct {
	Result ScenarioResult
	Cause  error
	// contains filtered or unexported fields
}

func NewScenarioError

func NewScenarioError(err error, result ScenarioResult, cause error) *ScenarioError

func (*ScenarioError) Error

func (e *ScenarioError) Error() string

func (*ScenarioError) Unwrap

func (e *ScenarioError) Unwrap() error

type ScenarioResult

type ScenarioResult struct {
	ScenarioId string
	StartedAt  time.Time

	StepResults []StepResult
}

type Scenarios

type Scenarios map[string]*Scenario

func (Scenarios) Run

func (s Scenarios) Run(ctx context.Context, scenarioNames ...string) error

type SimulationContext

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

type SimulationInitializer

type SimulationInitializer func(*SimulationContext)

type Step

type Step struct {
	Id          string        `json:"id"`
	Args        []interface{} `json:"args,omitempty"`
	Text        string        `json:"text"`
	Description string        `json:"description,omitempty"`
}

type StepResult

type StepResult struct {
	Status     StepStatus
	FinishedAt time.Time
	Err        error
	Returns    []interface{}
	ScenarioId string

	Step *Step
}

func NewStepResult

func NewStepResult(scenarioId string, step *Step) StepResult

type StepStatus

type StepStatus int
const (
	Passed StepStatus = iota
	Failed
	Skipped
	Undefined
	Pending
)

func (StepStatus) String

func (st StepStatus) String() string

String ...

Jump to

Keyboard shortcuts

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