runtime

package
v0.0.0-...-af4311f Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyContext

func CopyContext(dest, src *Context)

CopyContext copy content of context from src context

func ReconstructContext

func ReconstructContext(ctx *Context) error

ReconstructContext will reconstruct context from parent and previous variable patch

func RenderCleaners

func RenderCleaners(ctx *Context, ccs []types.CleanerConfig) error

RenderCleaners render cleaner config with current context and save into context

func RenderExports

func RenderExports(ctx *Context, exports []types.Var) error

RenderExports render export variables

func RenderPresetters

func RenderPresetters(ctx *Context, pcs []types.PresetConfig) error

RenderPresetters render preset config with current context and save into context

Types

type Cleaner

type Cleaner struct {
	// Name defines name of cleaner
	Name string
	// ForEach defines whether cleaner is called for each case
	ForEach bool
	// Args defines cleaner args
	Args map[string]string
}

Cleaner defines cleaner args

type Context

type Context struct {
	// Summary defines context summary
	Summary string

	// Parent defines parent context
	Parent *Context

	// Variables defines variables the context has
	Variables jsonutil.VariableMap

	// Exports defines variables exported by this context only
	Exports jsonutil.VariableMap

	// Presetters defines the presetters of context
	Presetters []Presetter

	// Cleaners defines the cleaners of context
	Cleaners []Cleaner

	// RoundTripTemplate defines template of roundtrip
	RoundTripTemplate *RoundTripTemplate
}

Context defines context of test cases

type Definition

type Definition struct {
	// Var defines Definition variable
	Var
	// Type defines variable from
	// enum ["body", "status", "header"]
	// default is body
	Type DefinitionType
}

Definition defines variable definitions

type DefinitionType

type DefinitionType string

DefinitionType defines where definition is from

const (
	// BodyType means definition from body
	BodyType DefinitionType = "body"
	// HeaderType means definition from header
	HeaderType DefinitionType = "header"
	// StatusType means definition from status
	StatusType DefinitionType = "status"
)

type Presetter

type Presetter struct {
	// Name defines presetter name
	Name string
	// Args defines args of presetter
	Args map[string]string
}

Presetter defines presetter args

type Request

type Request struct {
	// Scheme defines scheme of http request
	// e.g. http or https
	Scheme string

	// Host defines host of http request
	Host string

	// Method defines http method, e.g. GET
	Method string

	// Path defines http request path
	Path string

	// PathTemplate defines template of path
	// call fmt.Sprintf(PathTemplate, path) to generate real API path
	PathTemplate string

	// Headers defines http request header
	Headers map[string]string

	// Body defines http request body
	Body []byte
}

Request defines http request

type Response

type Response struct {
	// StatusCode checks response code
	StatusCode int

	// Headers defines http request header
	Headers map[string]string

	// Body defines http request body
	Body []byte

	// Async defines whether the task is a async task
	Async bool

	// Timeout defines deadline of checking
	Timeout time.Duration

	// Interval defines interval of polling and checking
	Interval time.Duration
}

Response defines http response

type RoundTrip

type RoundTrip struct {
	// RoundTripTemplate defines round trip template
	RoundTripTemplate

	// When defines round trip condition
	When *When

	// Definitions defines variables from response
	Definitions []Definition
}

RoundTrip defines a http round trip

func RenderRoundTrip

func RenderRoundTrip(ctx *Context, rtc *types.RoundTrip) (*RoundTrip, error)

RenderRoundTrip render template in round trip config with current context

type RoundTripTemplate

type RoundTripTemplate struct {
	// Client defines http client used by this roundtrip
	Client string

	// Request defines http request
	Request Request

	// Response defines http response validator
	Response Response
}

RoundTripTemplate defines template of round trip

func CopyRoundTripTemplate

func CopyRoundTripTemplate(rt *RoundTripTemplate) *RoundTripTemplate

CopyRoundTripTemplate will return a copy of round trip

type Var

type Var struct {
	// Name defines variable name
	Name string

	// Selector defines variable selector
	Selector []string
}

Var defines variable

type When

type When struct {
	// Expr defines condition expression
	Expr string

	// Args defines additional args
	Args map[string]string
}

When defines roundtrip condition

func RenderWhen

func RenderWhen(ctx *Context, whenConf *types.When) (*When, error)

RenderWhen will render condition config into runtime condition

Jump to

Keyboard shortcuts

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