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 ¶
type Expectation struct { Request RequestMatcher `json:"httpRequest,omitempty"` Response Response `json:"httpResponse,omitempty"` Priority int32 `json:"priority,omitempty"` }
func NewExpectation ¶
func NewExpectation(request RequestMatcher) *Expectation
func (Expectation) WithPriority ¶
func (e Expectation) WithPriority(priority int32) Expectation
func (Expectation) WithResponse ¶
func (e Expectation) WithResponse(response Response) Expectation
type MockServerClient ¶
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 ¶
func NewClientURL(url string) MockServerClient
NewClientURL creates a new client provided its URL
func (MockServerClient) Clear ¶
func (c MockServerClient) Clear(matcher RequestMatcher) error
Clear erases from the mock server all the requests matching the matcher.
func (MockServerClient) RegisterExpectation ¶
func (c MockServerClient) RegisterExpectation(expectation Expectation) error
Set a new Expectation in mock server with request and response
func (MockServerClient) SetDebug ¶
func (c MockServerClient) SetDebug(d bool) MockServerClient
SetDebug enables or disables the debug
func (MockServerClient) Verify ¶
func (c MockServerClient) Verify(matcher RequestMatcher, times Times) error
Verify checks if the mock server received requests matching the matcher.
func (MockServerClient) VerifyAndClear ¶
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 ¶
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"` KeepAlive bool `json:"keepAlive,omitempty"` Secure bool `json:"secure"` }
func (RequestMatcher) WithHeader ¶
func (m RequestMatcher) WithHeader(key, value string) RequestMatcher
func (RequestMatcher) WithJSONFields ¶
func (m RequestMatcher) WithJSONFields(json map[string]interface{}) RequestMatcher
type Response ¶
type Response struct { Body map[string]interface{} `json:"body,omitempty"` Headers map[string][]string `json:"headers,omitempty"` StatusCode int32 `json:"statusCode,omitempty"` }
func NewResponseOK ¶
func NewResponseOK() *Response