Documentation
¶
Index ¶
- func Contains(expected string, actual ...string) bool
- func Exists(value string) bool
- func Missing(value string) bool
- func MockPaths(r Router, paths *Fixtures)
- type Discriminator
- type Discriminators
- type Fixtures
- type Headers
- type Path
- type QueryParams
- type RequestDiscriminator
- type Resource
- type Response
- type Router
- type TemplatedFunction
- type TemplatedValues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Discriminator ¶
type Discriminator struct { When RequestDiscriminator `json:"when"` Response Response `json:"response"` }
type Discriminators ¶
type Discriminators []Discriminator
func (Discriminators) AtLeastOneDiscriminatorIsSatisfied ¶
func (arr Discriminators) AtLeastOneDiscriminatorIsSatisfied(req *http.Request) bool
type Headers ¶
type Headers struct { textproto.MIMEHeader TemplatedValues TemplatedValues }
Headers does what it says on the tin
func (*Headers) UnmarshalJSON ¶
UnmarshalJSON creates a textproto.MIMEHeader compliant struct using provided map values
type QueryParams ¶
type QueryParams struct { url.Values TemplatedValues TemplatedValues }
QueryParams does what it says on the tin
func (*QueryParams) UnmarshalJSON ¶
func (q *QueryParams) UnmarshalJSON(d []byte) error
UnmarshalJSON creates a url.Values compliant struct using the provided map values
type RequestDiscriminator ¶
type RequestDiscriminator struct { Headers Headers `json:"headers"` QueryParams QueryParams `json:"queryParams"` }
func NewRequestDiscriminator ¶
func NewRequestDiscriminator() RequestDiscriminator
func (RequestDiscriminator) SatisfiesDiscriminator ¶
func (r RequestDiscriminator) SatisfiesDiscriminator(req *http.Request) bool
type Resource ¶
type Resource struct { Discriminators Discriminators Response Response }
func (*Resource) UnmarshalJSON ¶
type Response ¶
type Response struct { Status int `json:"status"` Headers map[string]string `json:"headers"` Body interface{} `json:"body"` }
Response mocks a particular http method for a given path
type Router ¶
type Router interface { Get(path string, handler http.HandlerFunc, middleware ...vestigo.Middleware) Put(path string, handler http.HandlerFunc, middleware ...vestigo.Middleware) Post(path string, handler http.HandlerFunc, middleware ...vestigo.Middleware) Delete(path string, handler http.HandlerFunc, middleware ...vestigo.Middleware) }
Router allows us to test that paths are configured properly
type TemplatedFunction ¶
type TemplatedValues ¶
type TemplatedValues map[string]TemplatedFunction
TemplatedValues holds "special" values which can be used for fuzzy discriminators - i.e. ${exists} checks for the existence of the header
func ParseRequestValues ¶
func ParseRequestValues(rawValues map[string]string) (TemplatedValues, map[string]string)
Click to show internal directories.
Click to hide internal directories.