Documentation ¶
Index ¶
- Constants
- func Cast(v interface{}) string
- func ParseArrayIndexRef(selector string) (int, int)
- func ParseObjectFieldRef(selector string) (string, int)
- func Value(v string) func() string
- type BodyParameters
- type HeadersParameters
- type Map
- type MemorySource
- type MultiSet
- func (params *MultiSet) ClearData()
- func (params *MultiSet) Iterate() contract.ParameterIterator
- func (params *MultiSet) Load(src contract.ParameterSource)
- func (params *MultiSet) Reload()
- func (params *MultiSet) RememberSource(src contract.ParameterSource)
- func (params *MultiSet) Require(paramName string)
- func (params *MultiSet) StopRememberingSources()
- func (params *MultiSet) Validate() error
- type NullSource
- type QueryParameters
- type Reference
- type ReferenceAccess
- type ReferenceMap
- type ReferenceSource
- type Set
- type URLParameters
Constants ¶
const (
KeyHost = "HOSTNAME"
)
Various parameters that don't come from specs or input.
Variables ¶
This section is empty.
Functions ¶
func ParseArrayIndexRef ¶
ParseArrayIndexRef parses the JSON array index signature [N] in the beginning of selector. It returns the index and number of parsed characters when successful, and (-1, 0) when it was not able to parse.
func ParseObjectFieldRef ¶
ParseObjectFieldRef parses the JSON object field signature .fieldName in the beginning of selector. It returns the field name and number of parsed characters when successful, and ("", 0) when it was not able to parse.
Types ¶
type BodyParameters ¶
type BodyParameters struct { contract.EntityTrait *MultiSet }
BodyParameters is the source for request header parameters.
func Body ¶
func Body(log contract.Logger) *BodyParameters
Body creates a new BodyParameters instance.
type HeadersParameters ¶
type HeadersParameters struct { contract.EntityTrait *MultiSet }
HeadersParameters is the source for request header parameters.
func Headers ¶
func Headers(log contract.Logger) *HeadersParameters
Headers creates a new HeadersParameters instance.
type MemorySource ¶
MemorySource is a parameter source which uses a native map as a source storage.
func NewMemorySource ¶
func NewMemorySource(name string) *MemorySource
NewMemorySource creates a new MemoryParameterSource instance.
func (*MemorySource) Add ¶
func (ds *MemorySource) Add(n string, v string)
Add stores a kv pair in the source.
func (*MemorySource) Get ¶
func (ds *MemorySource) Get(pn string) string
Get returns a parameter by it's name.
func (*MemorySource) Iterate ¶
func (ds *MemorySource) Iterate() contract.ParameterIterator
Iterate returns an iterable channel to receive parameter tuples.
type MultiSet ¶
type MultiSet struct { Name string // contains filtered or unexported fields }
MultiSet is a set of named values used as input parameters for an operation. Each key can have multiple values.
func NewMultiSet ¶
NewMultiSet creates a new MultiSet instance.
func (*MultiSet) ClearData ¶
func (params *MultiSet) ClearData()
ClearData clears the data (but keeps the required parameters).
func (*MultiSet) Iterate ¶
func (params *MultiSet) Iterate() contract.ParameterIterator
Iterate creates an iterable channel.
func (*MultiSet) Load ¶
func (params *MultiSet) Load(src contract.ParameterSource)
Load reads parameters from a source.
func (*MultiSet) Reload ¶
func (params *MultiSet) Reload()
Reload re-reads parameters from the saved source.
func (*MultiSet) RememberSource ¶
func (params *MultiSet) RememberSource(src contract.ParameterSource)
RememberSource remembers the source to later Reload() from.
func (*MultiSet) StopRememberingSources ¶
func (params *MultiSet) StopRememberingSources()
StopRememberingSources disables the source remembering functionality (see Load).
type NullSource ¶
type NullSource struct {
errors.NullObjectPrototype
}
NullSource is a placeholder source used when we can't have a real one.
func NoSource ¶
func NoSource(err error, log contract.Logger) *NullSource
NoSource creates a new NullSource instance.
func (*NullSource) Iterate ¶
func (ds *NullSource) Iterate() contract.ParameterIterator
Iterate reports an error.
type QueryParameters ¶
type QueryParameters struct { contract.EntityTrait *MultiSet }
QueryParameters is the source for URL query parameters.
func Query ¶
func Query(log contract.Logger) *QueryParameters
Query creates a new QueryParameters instance.
type Reference ¶
type Reference struct { OpID string Result *contract.OperationResult Selector string Log contract.Logger }
Reference is a special kind of parameter which comes from an operation response. When a parameter for some operation in a script has a value like "operationID.response.[0].user.id" this means that the actual value comes from JSON response of the operation "operationID" and it's exact location is "[0].user.id" field.
func (Reference) Value ¶
func (pr Reference) Value() contract.ParameterAccess
Value returns a parameter access function which computes and returns a real value.
type ReferenceAccess ¶
ReferenceAccess is a function to compute and return a referenced value.
func AccessArray ¶
func AccessArray(access ReferenceAccess, i int) ReferenceAccess
AccessArray treats v as an array and returns i-th element of it.
func AccessObject ¶
func AccessObject(access ReferenceAccess, f string) ReferenceAccess
AccessObject treats v as a map and returns f-th element of it.
func NoAccess ¶
func NoAccess(err error) ReferenceAccess
NoAccess is a placeholder ref access function used when we can't have a real one. Usually when it is impossible to parse a reference selector.
func ParseSelector ¶
func ParseSelector(selector string, log contract.Logger) (ReferenceAccess, string)
ParseSelector parses selectors and constructs a parameter access function from it.
type ReferenceMap ¶
ReferenceMap is a multimap of ParameterReferences.
type ReferenceSource ¶
type ReferenceSource struct { contract.EntityTrait Refs ReferenceMap }
ReferenceSource is a parameter source backed by a response of other operations. When you want to use some of response data as a input for an operation test, you add references here then Load() them into a target parameter set.
func NewReferenceSource ¶
func NewReferenceSource(log contract.Logger) *ReferenceSource
NewReferenceSource creates a new ReferenceSource instance.
func (*ReferenceSource) AddReference ¶
func (src *ReferenceSource) AddReference(pn string, opID string, result *contract.OperationResult, selector string)
AddReference adds a reference to a parameter value, located in response of op.
func (*ReferenceSource) Iterate ¶
func (src *ReferenceSource) Iterate() contract.ParameterIterator
Iterate creates an iterable channel.
type Set ¶
type Set struct {
*MultiSet
}
Set is a set of parameters used in operation testing. It is basically a MultiSet, the only difference being is that Load() overwrites each key with a [1]string instead of appending them.
func (*Set) Load ¶
func (params *Set) Load(src contract.ParameterSource)
Load reads parameters from a source.
type URLParameters ¶
type URLParameters struct { contract.EntityTrait *Set Path string }
URLParameters is the source for URL path parameters. URLParameters have an implicit requirement for the @HOSTNAME parameter which is an API host name.
func URL ¶
func URL(path string, log contract.Logger) *URLParameters
URL creates a new URLParameters instance.
func (URLParameters) String ¶
func (params URLParameters) String() string
Make creates a URL string value from path template and parameters it has.