Documentation
¶
Index ¶
- Constants
- type BodyMatcher
- type Expectation
- type ExpectationResponse
- type MockClient
- func (c MockClient) Clear(matcher RequestMatcher) error
- func (c MockClient) RegisterExpectation(expectation Expectation) error
- func (c MockClient) SetDebug(d bool) MockClient
- func (c MockClient) Verify(matcher RequestMatcher, times Times) error
- func (c MockClient) VerifyAndClear(matcher RequestMatcher, times Times) error
- func (c MockClient) VerifyAndClearByHeader(headerName, headerValue string, matcher RequestMatcher, times Times) error
- type RequestMatcher
- type Times
Constants ¶
View Source
const ( StrictMatch = "STRICT" TolerantMatch = "ONLY_MATCHING_FIELDS" )
View Source
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 ExpectationResponse `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 ExpectationResponse) Expectation
type ExpectationResponse ¶ added in v0.2.0
type ExpectationResponse 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() *ExpectationResponse
func (ExpectationResponse) WithHeader ¶ added in v0.2.0
func (e ExpectationResponse) WithHeader(key, value string) ExpectationResponse
func (ExpectationResponse) WithJSONBody ¶ added in v0.2.0
func (e ExpectationResponse) WithJSONBody(json map[string]interface{}) ExpectationResponse
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(host string, port int) MockClient
func (MockClient) Clear ¶
func (c MockClient) Clear(matcher RequestMatcher) error
Clear erases from the mock server all the requests matching the matcher.
func (MockClient) RegisterExpectation ¶ added in v0.2.0
func (c MockClient) RegisterExpectation(expectation Expectation) error
Set a new Expectation in mock server with request and response
func (MockClient) SetDebug ¶ added in v0.2.0
func (c MockClient) SetDebug(d bool) MockClient
SetDebug enables or disables the debug
func (MockClient) Verify ¶
func (c MockClient) Verify(matcher RequestMatcher, times Times) error
Verify checks if the mock server received requests matching the matcher.
func (MockClient) VerifyAndClear ¶
func (c MockClient) 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 (MockClient) VerifyAndClearByHeader ¶
func (c MockClient) 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
Click to show internal directories.
Click to hide internal directories.