scenario

package
v0.0.0-...-faec9f9 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextGetter

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

func NewContextGetter

func NewContextGetter(s *Scenario) *ContextGetter

func (ContextGetter) Lookup

func (x ContextGetter) Lookup(s string) (string, bool, error)

type InlineExecutor

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

func NewInlineExecutor

func NewInlineExecutor(s *Scenario) *InlineExecutor

func (InlineExecutor) Lookup

func (x InlineExecutor) Lookup(s string) (string, bool, error)

type Meta

type Meta struct {
	Ext    string
	Params []string
}

type Module

type Module struct{}

type ParamQuoter

type ParamQuoter struct {
	Scen *Scenario
}

func (ParamQuoter) Lookup

func (l ParamQuoter) Lookup(s string) (string, bool, error)

type Scenario

type Scenario struct {
	Steps []interface{}
	M     Module

	// Contains the variables
	Context []map[string]string

	// Contains the storage for the modules
	Store map[string]interface{}

	// Cleanup functions, set by modules
	Cleanup map[string]func(*Scenario) error

	// Functions
	Functions map[string][]interface{}

	Quoter      ParamQuoter
	SubstQuoter *text.StringSubstitutor

	Executor      *InlineExecutor
	SubstExecutor *text.StringSubstitutor

	Subst *text.StringSubstitutor

	// Caller, when the scenario is called from another one
	Caller *Scenario

	// Root, from where looking from modules
	Root string

	// Channel for errors
	// If an error is posted on the channel, the scenario stops
	ErrorChan chan (error)

	// Indicates if we are in a local function
	// It impacts the return steps
	InFunction bool

	Skip bool
	// contains filtered or unexported fields
}

func NewScenario

func NewScenario() *Scenario

func (*Scenario) AddVariables

func (s *Scenario) AddVariables(params map[string]interface{}) error

func (*Scenario) CopyVariable

func (s *Scenario) CopyVariable(name string, source *Scenario) error

func (*Scenario) CopyVariables

func (s *Scenario) CopyVariables(source *Scenario) error

Add all the variables from params, excluding builtin variables

func (*Scenario) DeleteContext

func (s *Scenario) DeleteContext(name string)

Removes a variable from the context

func (*Scenario) DeleteContextAs

func (s *Scenario) DeleteContextAs(params map[string]interface{}, defprefix string, name string)

Delete a variable in the context Gets the "as" parameter from the params map, then builds the name of the variable If "as" is not set, the name of the variable will be <defprefix>.<name> Else, the prefix will be the value of the "as" parameter If the "as" parameter is an empty string, then the name of the variable will be <name> (without prefix)

func (*Scenario) DeleteContextRegex

func (s *Scenario) DeleteContextRegex(regex string)

Removes variables matching a regex from the context

func (*Scenario) DoCleanup

func (s *Scenario) DoCleanup()

Calls the cleanup functions set by the modules, if any

func (*Scenario) Exec

func (s *Scenario) Exec(val string, params map[string]interface{}) error

Execute a node. Locates the function in the module, and call it.

func (*Scenario) Expand

func (s *Scenario) Expand(params interface{}) (interface{}, error)

Replace the values

func (*Scenario) ExpandList

func (s *Scenario) ExpandList(params []interface{}) ([]interface{}, error)

Replace the values of the variables in a list

func (*Scenario) ExpandMap

func (s *Scenario) ExpandMap(params map[string]interface{}) (map[string]interface{}, error)

Replace the values of the variables in a map

func (*Scenario) ExpandString

func (s *Scenario) ExpandString(param string) (string, error)

Replace the value of the variable

func (*Scenario) ExtractFunctions

func (s *Scenario) ExtractFunctions(steps []interface{}) error

Extracts the functions and put them in the "Functions" map, for later call

func (*Scenario) GetBool

func (s *Scenario) GetBool(params map[string]interface{}, key string, def interface{}) (bool, error)

Get a parameter as boolean. Returns the default value if not found. If the value is not found, and there is no default value, returns an error. If the value is not a string, return an error

func (*Scenario) GetContext

func (s *Scenario) GetContext(name string) (string, bool)

Gets a variable from the context stack

func (*Scenario) GetList

func (s *Scenario) GetList(params map[string]interface{}, key string, def interface{}) ([]interface{}, error)

Get a parameter as list. Returns the default value if not found. If the value is not found, and there is no default value, returns an error. If the value is not a list, return an error

func (*Scenario) GetMap

func (s *Scenario) GetMap(params map[string]interface{}, key string, def interface{}) (map[string]interface{}, error)

Get a parameter as map. Returns the default value if not found. If the value is not found, and there is no default value, or the default value is not a map returns an error. If the value is not a map, return an error

func (*Scenario) GetModule

func (s *Scenario) GetModule() string

func (*Scenario) GetNumber

func (s *Scenario) GetNumber(params map[string]interface{}, key string, def interface{}) (int, error)

Get a parameter as integer. Returns the default value if not found. If the value is not found, and there is no default value, returns an error. If the value is not a string, return an error

func (*Scenario) GetSteps

func (s *Scenario) GetSteps(params map[string]interface{}, key string, def []map[string]interface{}) ([]map[string]interface{}, error)

Get a parameter as steps (a list of maps). Returns the default value if not found. If the value is not found, and there is no default value, or the default value is not a list of maps returns an error. If the value is not a list of maps, return an error

func (*Scenario) GetStore

func (s *Scenario) GetStore(name string) interface{}

Get data from the store

func (*Scenario) GetString

func (s *Scenario) GetString(params map[string]interface{}, key string, def interface{}) (string, error)

Get a parameter as string. Returns the default value if not found. If the value is not found, and there is no default value, returns an error. If the value is not a string, return an error

func (*Scenario) Meta

func (s *Scenario) Meta(val string) Meta

Gets the meta-informations on a module

func (*Scenario) PutCleanup

func (s *Scenario) PutCleanup(k string, f func(*Scenario) error)

A module puts a cleanup function

func (*Scenario) PutContext

func (s *Scenario) PutContext(name string, value interface{}) error

Put a variable in the context

func (*Scenario) PutContextAs

func (s *Scenario) PutContextAs(params map[string]interface{}, defprefix string, name string, value interface{}) error

Put a variable in the context Gets the "as" parameter from the params map, then builds the name of the variable If "as" is not set, the name of the variable will be <defprefix>.<name> Else, the prefix will be the value of the "as" parameter If the "as" parameter is an empty string, then the name of the variable will be <name> (without prefix)

func (*Scenario) PutContextCallerFunctio

func (s *Scenario) PutContextCallerFunctio(name string, value interface{}) error

Put a variable in the context of the caller function

func (*Scenario) PutStore

func (s *Scenario) PutStore(name string, value interface{})

Put data in the store

func (*Scenario) RemoveStore

func (s *Scenario) RemoveStore(name string)

Remove data from the store

func (*Scenario) Run

func (s *Scenario) Run(scen string) error

func (*Scenario) RunFromRoot

func (s *Scenario) RunFromRoot(scen string) error

func (*Scenario) RunFunction

func (s *Scenario) RunFunction(scen string, fun string) error

func (*Scenario) RunSteps

func (s *Scenario) RunSteps(steps []interface{}) error

type Step

type Step struct {
	Origin map[string]interface{}
	Type   string
	Desc   string
	Value  string
	Params map[string]interface{}
	Steps  []interface{}

	M Module
	// contains filtered or unexported fields
}

func NewStep

func NewStep(n map[string]interface{}, s *Scenario) *Step

Construct a new Step from the YAML node

func (*Step) Exec

func (s *Step) Exec() error

func (Step) ToString

func (s Step) ToString() string

Jump to

Keyboard shortcuts

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