context

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package context provides the test context of scenarigo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunWithRetry added in v0.14.0

func RunWithRetry(c *Context, name string, f func(*Context), policy reporter.RetryPolicy) bool

RunWithRetry runs f as a subtest of c called name with retry.

Types

type Context

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

Context represents a scenarigo context.

func FromT

func FromT(t *testing.T) *Context

FromT creates a new context from t.

func New

func New(r reporter.Reporter) *Context

New returns a new scenarigo context.

func (*Context) EnabledColor added in v0.3.0

func (c *Context) EnabledColor() bool

EnabledColor returns whether color output is enabled.

func (*Context) ExecuteTemplate

func (c *Context) ExecuteTemplate(i interface{}) (interface{}, error)

ExecuteTemplate executes template strings in context.

func (*Context) ExtractByKey

func (c *Context) ExtractByKey(key string) (interface{}, bool)

ExtractByKey implements query.KeyExtractor interface.

func (*Context) Node added in v0.3.0

func (c *Context) Node() ast.Node

Node returns the ast.Node.

func (*Context) PluginDir

func (c *Context) PluginDir() string

PluginDir returns the plugins root directory.

func (*Context) Plugins

func (c *Context) Plugins() Plugins

Plugins returns the plugins.

func (*Context) Reporter

func (c *Context) Reporter() reporter.Reporter

Reporter returns the reporter of context.

func (*Context) Request

func (c *Context) Request() interface{}

Request returns the request.

func (*Context) RequestContext

func (c *Context) RequestContext() context.Context

RequestContext returns the context.Context for request.

func (*Context) Response

func (c *Context) Response() interface{}

Response returns the response.

func (*Context) Run

func (c *Context) Run(name string, f func(*Context)) bool

Run runs f as a subtest of c called name.

func (*Context) ScenarioFilepath added in v0.6.0

func (c *Context) ScenarioFilepath() string

ScenarioFilepath returns the filepath of the scenario executing in this context.

func (*Context) Steps added in v0.16.0

func (c *Context) Steps() *Steps

Steps returns the steps.

func (*Context) Vars

func (c *Context) Vars() Vars

Vars returns the context variables.

func (*Context) WithEnabledColor added in v0.3.0

func (c *Context) WithEnabledColor(enabledColor bool) *Context

WithEnabledColor returns a copy of c with enabledColor flag.

func (*Context) WithNode added in v0.3.0

func (c *Context) WithNode(node ast.Node) *Context

WithNode returns a copy of c with ast.Node.

func (*Context) WithPluginDir

func (c *Context) WithPluginDir(path string) *Context

WithPluginDir returns a copy of c with plugin root directory.

func (*Context) WithPlugins

func (c *Context) WithPlugins(ps map[string]interface{}) *Context

WithPlugins returns a copy of c with ps.

func (*Context) WithReporter

func (c *Context) WithReporter(r reporter.Reporter) *Context

WithReporter returns a copy of c with new test reporter.

func (*Context) WithRequest

func (c *Context) WithRequest(req interface{}) *Context

WithRequest returns a copy of c with request.

func (*Context) WithRequestContext

func (c *Context) WithRequestContext(reqCtx context.Context) *Context

WithRequestContext returns the context.Context for request.

func (*Context) WithResponse

func (c *Context) WithResponse(resp interface{}) *Context

WithResponse returns a copy of c with response.

func (*Context) WithScenarioFilepath added in v0.6.0

func (c *Context) WithScenarioFilepath(path string) *Context

WithScenarioFilepath returns a copy of c with the scenario filepath.

func (*Context) WithSteps added in v0.16.0

func (c *Context) WithSteps(steps *Steps) *Context

WithSteps returns a copy of c with steps.

func (*Context) WithVars

func (c *Context) WithVars(v interface{}) *Context

WithVars returns a copy of c with v.

type Plugins

type Plugins []map[string]interface{}

Plugins represents plugins.

func (Plugins) Append

func (plugins Plugins) Append(ps map[string]interface{}) Plugins

Append appends p to plugins.

func (Plugins) ExtractByKey

func (plugins Plugins) ExtractByKey(key string) (interface{}, bool)

ExtractByKey implements query.KeyExtractor interface.

type Step added in v0.16.0

type Step struct {
	Result string `yaml:"result,omitempty"`
	Steps  *Steps `yaml:"steps,omitempty"` // child steps
}

Step represents a result of step.

type Steps added in v0.16.0

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

Steps represents results of steps.

func NewSteps added in v0.16.0

func NewSteps() *Steps

NewStesp returns a *Steps.

func (*Steps) Add added in v0.16.0

func (s *Steps) Add(id string, step *Step)

Add adds a result of step.

func (*Steps) ExtractByKey added in v0.16.0

func (s *Steps) ExtractByKey(key string) (interface{}, bool)

ExtractByKey implements query.KeyExtractor interface.

func (*Steps) Get added in v0.16.0

func (s *Steps) Get(id string) *Step

Get gets a result of step by id.

type Vars

type Vars []interface{}

Vars represents context variables.

func (Vars) Append

func (vars Vars) Append(v interface{}) Vars

Append appends v to context variables.

func (Vars) ExtractByKey

func (vars Vars) ExtractByKey(key string) (interface{}, bool)

ExtractByKey implements query.KeyExtractor interface.

Jump to

Keyboard shortcuts

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