Documentation ¶
Overview ¶
Package extract defines all the possible extraction methods that can be applied on a response.
Signatures ¶
it is important for consistency that each extractor follow the same function signature:
func(r RequestTest, resp *http.Response, env map[string]interface{})
this will allow easier refactoring or interfacing later on if this becomes necessary.
Package format defines the format of a Litmus test file, as represented in code.
Index ¶
- func Body(r *RequestTest, resp *http.Response, env map[string]interface{}) error
- func Header(r *RequestTest, resp *http.Response, env map[string]interface{}) error
- func ProcessResponse(r *RequestTest, resp *http.Response, env map[string]interface{}) error
- func StatusCode(r *RequestTest, resp *http.Response, _ map[string]interface{}) error
- type BodyGetter
- type GetterConfig
- type GetterConfigs
- type HeaderGetter
- type JSONBodyGetter
- type KeyValuePair
- type KeyValuePairs
- type Litmus
- type RequestTest
- type TestFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Body ¶
func Body(r *RequestTest, resp *http.Response, env map[string]interface{}) error
Payload - checks the body against the expected value
func Header ¶
func Header(r *RequestTest, resp *http.Response, env map[string]interface{}) error
Header - extracts a header value and checks it against the expected value
func ProcessResponse ¶
func ProcessResponse(r *RequestTest, resp *http.Response, env map[string]interface{}) error
func StatusCode ¶
func StatusCode(r *RequestTest, resp *http.Response, _ map[string]interface{}) error
StatusCode - extracts the status code and checks it against the expected value
Types ¶
type BodyGetter ¶
BodyGetter defines the behavior or something that can extract information from a response body.
func NewBodyGetter ¶
func NewBodyGetter(resp *http.Response) (e BodyGetter, err error)
NewBodyGetter returns the body extracter based on the Content-Type found in the response headers.
type GetterConfig ¶
type GetterConfig struct { Path string `toml:"path" yaml:"path"` Set string `toml:"set" yaml:"set"` Type string `toml:"type" yaml:"type"` Expected string `toml:"exp" yaml:"exp"` }
GetterConfig provides the information required to get data from a response.
type HeaderGetter ¶
type HeaderGetter struct{}
HeaderGetter extracts information from response headers.
type JSONBodyGetter ¶
type JSONBodyGetter struct{}
JSONBodyGetter extracts information from a response body using JSON dot notation.
type KeyValuePair ¶
KeyValuePair allows a map to be expressed in slice form.
type KeyValuePairs ¶
type KeyValuePairs []KeyValuePair
KeyValuePairs is a slice of KeyValuePair.
func (*KeyValuePairs) Set ¶
func (k *KeyValuePairs) Set(value string) error
Set adds an item to KeyValuePairs.
func (*KeyValuePairs) String ¶
func (k *KeyValuePairs) String() string
String returns the string representation of KeyValuePairs.
func (*KeyValuePairs) Type ¶
func (k *KeyValuePairs) Type() string
Type returns a string representation of the type of KeyValuePairs
type Litmus ¶
type Litmus struct { // test is singular to enable singular dot notation in the file Test []RequestTest }
type RequestTest ¶
type RequestTest struct { Name string `toml:"name" yaml:"name"` Method string `toml:"method" yaml:"method"` URL string `toml:"url" yaml:"url"` Headers map[string]string `toml:"headers" yaml:"headers"` Query map[string]string `toml:"query" yaml:"query"` Payload string `toml:"payload" yaml:"payload"` BodyModifiers map[string]interface{} `toml:"bodymod" yaml:"bodymod"` Body map[string]interface{} `toml:"body" yaml:"body"` Head map[string]interface{} `toml:"head" yaml:"head"` WantsCode int `toml:"wants_code" yaml:"wants_code"` }
RequestTest defines all the necessary fields to define a Litmus test
func (*RequestTest) ApplyEnv ¶
func (r *RequestTest) ApplyEnv(env map[string]interface{}) (err error)