Documentation ¶
Index ¶
- Constants
- type BodyMatcher
- type Expectation
- type MockServerClient
- func (c MockServerClient) Clear(matcher RequestMatcher) error
- func (c MockServerClient) RegisterExpectation(expectation Expectation) error
- func (c MockServerClient) SetDebug(d bool) MockServerClient
- func (c MockServerClient) Verify(matcher RequestMatcher, times Times) error
- func (c MockServerClient) VerifyAndClear(matcher RequestMatcher, times Times) error
- func (c MockServerClient) VerifyAndClearByHeader(headerName, headerValue string, matcher RequestMatcher, times Times) error
- type RequestMatcher
- type Response
- type Times
Constants ¶
const ( StrictMatch = "STRICT" TolerantMatch = "ONLY_MATCHING_FIELDS" )
const (
MatchBodyJSON = "JSON"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyMatcher ¶
type Expectation ¶ added in v0.2.0
type Expectation struct { Request RequestMatcher `json:"httpRequest,omitempty"` Response Response `json:"httpResponse,omitempty"` Priority int32 `json:"priority,omitempty"` }
func NewExpectation ¶ added in v0.2.0
func NewExpectation(request RequestMatcher) *Expectation
func (Expectation) WithPriority ¶ added in v0.2.0
func (e Expectation) WithPriority(priority int32) Expectation
func (Expectation) WithResponse ¶ added in v0.2.0
func (e Expectation) WithResponse(response Response) Expectation
type MockServerClient ¶ added in v0.2.2
type MockServerClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(host string, port int) MockServerClient
NewClient creates a new client provided its host and port
func NewClientURL ¶ added in v0.2.1
func NewClientURL(url string) MockServerClient
NewClientURL creates a new client provided its URL
func (MockServerClient) Clear ¶ added in v0.2.2
func (c MockServerClient) Clear(matcher RequestMatcher) error
Clear erases from the mock server all the requests matching the matcher.
func (MockServerClient) RegisterExpectation ¶ added in v0.2.2
func (c MockServerClient) RegisterExpectation(expectation Expectation) error
Set a new Expectation in mock server with request and response
func (MockServerClient) SetDebug ¶ added in v0.2.2
func (c MockServerClient) SetDebug(d bool) MockServerClient
SetDebug enables or disables the debug
func (MockServerClient) Verify ¶ added in v0.2.2
func (c MockServerClient) Verify(matcher RequestMatcher, times Times) error
Verify checks if the mock server received requests matching the matcher.
func (MockServerClient) VerifyAndClear ¶ added in v0.2.2
func (c MockServerClient) VerifyAndClear(matcher RequestMatcher, times Times) error
VerifyAndClear checks if the mock server received requests matching the matcher and then erases from the logs the requests matching the matcher.
func (MockServerClient) VerifyAndClearByHeader ¶ added in v0.2.2
func (c MockServerClient) VerifyAndClearByHeader(headerName, headerValue string, matcher RequestMatcher, times Times) error
VerifyAndClearByHeader checks if the mock server received requests matching the matcher and having the specified header name and value. It then erases from the logs the requests matching the same header name and value.
type RequestMatcher ¶
type RequestMatcher struct { Method string `json:"method,omitempty"` Path string `json:"path,omitempty"` Body BodyMatcher `json:"body,omitempty"` Headers map[string][]string `json:"headers,omitempty"` }
func (RequestMatcher) WithHeader ¶
func (m RequestMatcher) WithHeader(key, value string) RequestMatcher
func (RequestMatcher) WithJSONFields ¶ added in v0.2.0
func (m RequestMatcher) WithJSONFields(json map[string]interface{}) RequestMatcher
type Response ¶ added in v0.2.1
type Response struct { Body map[string]interface{} `json:"body,omitempty"` Headers map[string][]string `json:"headers,omitempty"` StatusCode int32 `json:"statusCode,omitempty"` }
func NewResponseOK ¶ added in v0.2.0
func NewResponseOK() *Response