Documentation ¶
Index ¶
- type CheckerFunc
- type Client
- type ClientFunc
- type ClientMock
- type DecoratorFunc
- type Promise
- type PromiseBuilder
- func (b *PromiseBuilder) Get(path string) *PromiseBuilder
- func (b *PromiseBuilder) Post(path string) *PromiseBuilder
- func (b *PromiseBuilder) WillReturn(code int, body string)
- func (b *PromiseBuilder) WillReturnResponse(response *http.Response)
- func (b *PromiseBuilder) WithBody(body string) *PromiseBuilder
- func (b *PromiseBuilder) WithBodyReader(body io.Reader) *PromiseBuilder
- func (b *PromiseBuilder) WithChecker(checker CheckerFunc) *PromiseBuilder
- func (b *PromiseBuilder) WithHeader(key, value string) *PromiseBuilder
- func (b *PromiseBuilder) WithHost(host string) *PromiseBuilder
- func (b *PromiseBuilder) WithMethod(method string) *PromiseBuilder
- func (b *PromiseBuilder) WithPath(path string) *PromiseBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckerFunc ¶
CheckerFunc checks if request fits conditions
type Client ¶
Client sends http.Requests and returns http.Responses or errors in case of failure.
func Decorate ¶
func Decorate(c Client, ds ...DecoratorFunc) Client
Decorate decorates a Client c with all the given Decorators, in order.
type ClientFunc ¶
ClientFunc is a function type that implements the Client interface.
type ClientMock ¶
type ClientMock struct {
// contains filtered or unexported fields
}
ClientMock implementation of Client for testing purpose
func (*ClientMock) Get ¶
func (c *ClientMock) Get(path string) *PromiseBuilder
Get is a helper method for using PromiseBuilder
func (*ClientMock) Post ¶
func (c *ClientMock) Post(path string) *PromiseBuilder
Post is a helper method for using PromiseBuilder
func (*ClientMock) Request ¶
func (c *ClientMock) Request() *PromiseBuilder
Request is a helper method that returns empty PromiseBuilder It should be used if you just want to mock response and don't need to check request method, path and/or body
type DecoratorFunc ¶
DecoratorFunc wraps a Client with extra behaviour.
type Promise ¶
type Promise struct {
// contains filtered or unexported fields
}
Promise is a combination of some checker functions and response.
type PromiseBuilder ¶
type PromiseBuilder struct {
// contains filtered or unexported fields
}
PromiseBuilder helper for creating rules with fluent interface
func NewPromiseBuilder ¶
func NewPromiseBuilder(client *ClientMock) *PromiseBuilder
NewPromiseBuilder constructor for ruleBuilder. all created constrains are registered in client
func (*PromiseBuilder) Get ¶
func (b *PromiseBuilder) Get(path string) *PromiseBuilder
Get checks that HTTP Method equals to GET
func (*PromiseBuilder) Post ¶
func (b *PromiseBuilder) Post(path string) *PromiseBuilder
Post checks that HTTP Method equals to POST
func (*PromiseBuilder) WillReturn ¶
func (b *PromiseBuilder) WillReturn(code int, body string)
WillReturn registers builded rule in client
func (*PromiseBuilder) WillReturnResponse ¶
func (b *PromiseBuilder) WillReturnResponse(response *http.Response)
WillReturnResponse registers builded rule in client
func (*PromiseBuilder) WithBody ¶
func (b *PromiseBuilder) WithBody(body string) *PromiseBuilder
WithBody checks that body equals to specified
func (*PromiseBuilder) WithBodyReader ¶
func (b *PromiseBuilder) WithBodyReader(body io.Reader) *PromiseBuilder
WithBodyReader checks that body equals to specified
func (*PromiseBuilder) WithChecker ¶
func (b *PromiseBuilder) WithChecker(checker CheckerFunc) *PromiseBuilder
WithChecker adds custorm checker
func (*PromiseBuilder) WithHeader ¶
func (b *PromiseBuilder) WithHeader(key, value string) *PromiseBuilder
WithHeader checks that request contains specified header with specified value
func (*PromiseBuilder) WithHost ¶
func (b *PromiseBuilder) WithHost(host string) *PromiseBuilder
WithHost checks that request host equals to specified
func (*PromiseBuilder) WithMethod ¶
func (b *PromiseBuilder) WithMethod(method string) *PromiseBuilder
WithMethod checks that HTTP Method equals to specified method
func (*PromiseBuilder) WithPath ¶
func (b *PromiseBuilder) WithPath(path string) *PromiseBuilder
WithPath checks that path equals to specified