Documentation
¶
Index ¶
- type Client
- type ClientResponse
- func (c ClientResponse) Expect(t *testing.T, eval func(c ClientResponse) error) ClientResponse
- func (c ClientResponse) ExpectError(t *testing.T, err error) ClientResponse
- func (c ClientResponse) ExpectHeaderEmpty(t *testing.T, key string) ClientResponse
- func (c ClientResponse) ExpectHeaderMatch(t *testing.T, key string, re *regexp.Regexp) ClientResponse
- func (c ClientResponse) ExpectHeaderValue(t *testing.T, key string, value string) ClientResponse
- func (c ClientResponse) ExpectStatus(t *testing.T, status int) ClientResponse
- func (c ClientResponse) OptionalHeaderMatch(t *testing.T, key string, re *regexp.Regexp) ClientResponse
- func (c ClientResponse) OptionalHeaderValue(t *testing.T, key string, value string) ClientResponse
- type Endpoints
- type JSONResponse
- func (c JSONResponse) Expect(t *testing.T, eval func(c JSONResponse) error) JSONResponse
- func (c JSONResponse) ExpectError(t *testing.T, err error) JSONResponse
- func (c JSONResponse) ExpectHeaderEmpty(t *testing.T, key string) JSONResponse
- func (c JSONResponse) ExpectHeaderMatch(t *testing.T, key string, re *regexp.Regexp) JSONResponse
- func (c JSONResponse) ExpectHeaderValue(t *testing.T, key string, value string) JSONResponse
- func (c JSONResponse) ExpectStatus(t *testing.T, status int) JSONResponse
- func (c JSONResponse) ExpectType(t *testing.T, key, typ string) JSONResponse
- func (c JSONResponse) ExpectTypes(t *testing.T, key string, typ ...string) JSONResponse
- func (c JSONResponse) ExpectValue(t *testing.T, key string, b interface{}) JSONResponse
- func (c JSONResponse) ExpectValueCount(t *testing.T, key string, count int) JSONResponse
- func (c JSONResponse) ExpectValueCountCompare(t *testing.T, key string, comp string, count int) JSONResponse
- func (c JSONResponse) ExpectValueMatch(t *testing.T, key string, re *regexp.Regexp) JSONResponse
- func (c JSONResponse) ExpectValueString(t *testing.T, key, b string) JSONResponse
- func (c JSONResponse) OptionalHeaderMatch(t *testing.T, key string, re *regexp.Regexp) JSONResponse
- func (c JSONResponse) OptionalHeaderValue(t *testing.T, key string, value string) JSONResponse
- func (c JSONResponse) OptionalType(t *testing.T, key, typ string) JSONResponse
- func (c JSONResponse) OptionalTypes(t *testing.T, key string, typ ...string) JSONResponse
- func (c JSONResponse) OptionalValue(t *testing.T, key string, b interface{}) JSONResponse
- func (c JSONResponse) OptionalValueMatch(t *testing.T, key string, re *regexp.Regexp) JSONResponse
- type ParamSpec
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { FollowRedirects bool Hostname string IdentityHeader string Port int Scheme string Endpoints map[string]Endpoints // Time is in MS Timeout int Client *http.Client }
Client parses a swagger.json document and exposes an interface for creating API calls to the endpoint specified.
func BuildClient ¶
BuildClient creates a new swagger dument from a file on the filesystem.
func (*Client) Exec ¶
func (sc *Client) Exec(specifier string, params map[string]interface{}) ClientResponse
Exec takes a path specifier and executes the corresponding functionality if found in the loaded swagger doc, returning a generic ClientResponse.
func (*Client) ExecJSON ¶
func (sc *Client) ExecJSON(specifier string, params map[string]interface{}) JSONResponse
ExecJSON takes a path specifier and executes the corresponding functionality if found in the loaded swagger doc, returning a JSONResponse.
func (*Client) MakeRequest ¶
func (sc *Client) MakeRequest(req *http.Request) ClientResponse
MakeRequest makes a request to a third party HTTP resource based on the given http.Request object.
type ClientResponse ¶
type ClientResponse struct { Body string `json:"body"` Cookies []*http.Cookie `json:"cookies"` Error error `json:"error"` Headers map[string]string `json:"headers"` RequestTime string `json:"request_time"` RequestURL string `json:"request_url"` Status string `json:"status"` StatusCode int `json:"status_code"` }
ClientResponse holds the pertinent information returned from a third party request.
func (ClientResponse) Expect ¶
func (c ClientResponse) Expect(t *testing.T, eval func(c ClientResponse) error) ClientResponse
Expect allows custom assertions to be run. A error returned from the eval function will cause the test to be failed.
func (ClientResponse) ExpectError ¶
func (c ClientResponse) ExpectError(t *testing.T, err error) ClientResponse
ExpectError is used to assert that a certain error condition has occured.
func (ClientResponse) ExpectHeaderEmpty ¶
func (c ClientResponse) ExpectHeaderEmpty(t *testing.T, key string) ClientResponse
ExpectHeaderEmpty asserts that there was no header value set at a given key.
func (ClientResponse) ExpectHeaderMatch ¶
func (c ClientResponse) ExpectHeaderMatch(t *testing.T, key string, re *regexp.Regexp) ClientResponse
ExpectHeaderMatch asserts that the header value at the given key will match the given regular expression.
func (ClientResponse) ExpectHeaderValue ¶
func (c ClientResponse) ExpectHeaderValue(t *testing.T, key string, value string) ClientResponse
ExpectHeaderValue asserts that the header value at the given key will match the given value.
func (ClientResponse) ExpectStatus ¶
func (c ClientResponse) ExpectStatus(t *testing.T, status int) ClientResponse
ExpectStatus asserts that a specific status code was received.
func (ClientResponse) OptionalHeaderMatch ¶
func (c ClientResponse) OptionalHeaderMatch(t *testing.T, key string, re *regexp.Regexp) ClientResponse
OptionalHeaderMatch differs from ExpectHeaderMatch in that it can only fail if the given key exists. If the key is missing entirely, the test will pass.
func (ClientResponse) OptionalHeaderValue ¶
func (c ClientResponse) OptionalHeaderValue(t *testing.T, key string, value string) ClientResponse
OptionalHeaderValue differs from ExpectHeaderValue in that it can only fail if the given key exists. If the key is missing entirely, the test will pass.
type JSONResponse ¶
type JSONResponse struct { ClientResponse Reader *gojson.JSONReader `json:"-"` }
JSONResponse is a ClientResponse with added functionality specifically for dealing with json API responses.
func (JSONResponse) Expect ¶
func (c JSONResponse) Expect(t *testing.T, eval func(c JSONResponse) error) JSONResponse
Expect allows custom assertions to be run. A error returned from the eval function will cause the test to be failed.
func (JSONResponse) ExpectError ¶
func (c JSONResponse) ExpectError(t *testing.T, err error) JSONResponse
ExpectError is used to assert that a certain error condition has occured.
func (JSONResponse) ExpectHeaderEmpty ¶
func (c JSONResponse) ExpectHeaderEmpty(t *testing.T, key string) JSONResponse
ExpectHeaderEmpty asserts that there was no header value set at a given key.
func (JSONResponse) ExpectHeaderMatch ¶
func (c JSONResponse) ExpectHeaderMatch(t *testing.T, key string, re *regexp.Regexp) JSONResponse
ExpectHeaderMatch asserts that the header value at the given key will match the given regular expression.
func (JSONResponse) ExpectHeaderValue ¶
func (c JSONResponse) ExpectHeaderValue(t *testing.T, key string, value string) JSONResponse
ExpectHeaderValue asserts that the header value at the given key will match the given value.
func (JSONResponse) ExpectStatus ¶
func (c JSONResponse) ExpectStatus(t *testing.T, status int) JSONResponse
ExpectStatus asserts that a specific status code was received.
func (JSONResponse) ExpectType ¶
func (c JSONResponse) ExpectType(t *testing.T, key, typ string) JSONResponse
ExpectType asserts the data type at the given key will match the given JSON data type.
func (JSONResponse) ExpectTypes ¶
func (c JSONResponse) ExpectTypes(t *testing.T, key string, typ ...string) JSONResponse
ExpectTypes asserts the data type at the given key will match the given JSON data types.
func (JSONResponse) ExpectValue ¶
func (c JSONResponse) ExpectValue(t *testing.T, key string, b interface{}) JSONResponse
ExpectValue asserts the value at the given key will match the given value.
func (JSONResponse) ExpectValueCount ¶
func (c JSONResponse) ExpectValueCount(t *testing.T, key string, count int) JSONResponse
ExpectValueCount asserts the aggregate data type at the given key will have the given number of child nodes.
func (JSONResponse) ExpectValueCountCompare ¶
func (c JSONResponse) ExpectValueCountCompare(t *testing.T, key string, comp string, count int) JSONResponse
ExpectValueCountCompare asserts the aggregate data type at the given key will have the given number of child nodes.
func (JSONResponse) ExpectValueMatch ¶
func (c JSONResponse) ExpectValueMatch(t *testing.T, key string, re *regexp.Regexp) JSONResponse
ExpectValueMatch asserts that the value at the given key will match the given regular expression.
func (JSONResponse) ExpectValueString ¶
func (c JSONResponse) ExpectValueString(t *testing.T, key, b string) JSONResponse
ExpectValueString asserts the value at the given key will match the given value. All comparisons are done as string comparisons.
func (JSONResponse) OptionalHeaderMatch ¶
func (c JSONResponse) OptionalHeaderMatch(t *testing.T, key string, re *regexp.Regexp) JSONResponse
OptionalHeaderMatch differs from ExpectHeaderMatch in that it can only fail if the given key exists. If the key is missing entirely, the test will pass.
func (JSONResponse) OptionalHeaderValue ¶
func (c JSONResponse) OptionalHeaderValue(t *testing.T, key string, value string) JSONResponse
OptionalHeaderValue differs from ExpectHeaderValue in that it can only fail if the given key exists. If the key is missing entirely, the test will pass.
func (JSONResponse) OptionalType ¶
func (c JSONResponse) OptionalType(t *testing.T, key, typ string) JSONResponse
OptionalType differs from ExpectType in that it can only fail if the given key exists. If the key is missing entirely, the test will pass.
func (JSONResponse) OptionalTypes ¶
func (c JSONResponse) OptionalTypes(t *testing.T, key string, typ ...string) JSONResponse
OptionalTypes differs from ExpectTypes in that it can only fail if the given key exists. If the key is missing entirely, the test will pass.
func (JSONResponse) OptionalValue ¶
func (c JSONResponse) OptionalValue(t *testing.T, key string, b interface{}) JSONResponse
OptionalValue differs from ExpectValue in that it can only fail if the given key exists. If the key is missing entirely, the test will pass.
func (JSONResponse) OptionalValueMatch ¶
func (c JSONResponse) OptionalValueMatch(t *testing.T, key string, re *regexp.Regexp) JSONResponse
OptionalValueMatch differs from ExpectValueMatch in that it can only fail if the given key exists. If the key is missing entirely, the test will pass.