Documentation ¶
Index ¶
- Constants
- Variables
- func ShouldBeEmpty(value interface{}, patterns ...interface{}) string
- func ShouldMatch(value interface{}, patterns ...interface{}) string
- func ShouldNotBeEmpty(value interface{}, patterns ...interface{}) string
- func ShouldNotMatch(value interface{}, patterns ...interface{}) string
- type Assertion
- type BodyMatcher
- func (bm BodyMatcher) MarshalJSON() ([]byte, error)
- func (bm BodyMatcher) MarshalYAML() (interface{}, error)
- func (bm BodyMatcher) Match(headers http.Header, value string) bool
- func (bm *BodyMatcher) UnmarshalJSON(data []byte) error
- func (bm *BodyMatcher) UnmarshalYAML(unmarshal func(interface{}) error) error
- type Context
- type Delay
- type DynamicMockResponse
- type Engine
- type Entry
- type GraphConfig
- type GraphEntry
- type GraphHistory
- type History
- type MapStringSlice
- type Mock
- type MockContext
- type MockProxy
- type MockRequest
- type MockResponse
- type MockState
- type Mocks
- type MultiMapMatcher
- type Request
- type Response
- type Session
- type SessionSummary
- type Sessions
- type StringMatcher
- type StringMatcherSlice
- type StringSlice
- type VerifyResult
Constants ¶
View Source
const ( StatusSmockerInternalError = 600 StatusSmockerEngineExecutionError = 601 StatusSmockerProxyRedirectionError = 602 StatusSmockerMockNotFound = 666 SmockerInternalError = "Smocker internal error" SmockerEngineExecutionError = "Error during template engine execution" SmockerProxyRedirectionError = "Error during request redirection" SmockerMockNotFound = "No mock found matching the request" SmockerMockExceeded = "Matching mock found but was exceeded" )
View Source
const ContextKey = "Context"
View Source
const (
DefaultMatcher = "ShouldEqual"
)
Variables ¶
View Source
var MockNotFound = fmt.Errorf("mock not found")
View Source
var SessionNotFound = fmt.Errorf("session not found")
View Source
var TemplateEngines = [...]Engine{GoTemplateEngineID, GoTemplateYamlEngineID, GoTemplateJsonEngineID, LuaEngineID}
Functions ¶
func ShouldBeEmpty ¶
func ShouldBeEmpty(value interface{}, patterns ...interface{}) string
func ShouldMatch ¶
func ShouldMatch(value interface{}, patterns ...interface{}) string
func ShouldNotBeEmpty ¶
func ShouldNotBeEmpty(value interface{}, patterns ...interface{}) string
func ShouldNotMatch ¶
func ShouldNotMatch(value interface{}, patterns ...interface{}) string
Types ¶
type BodyMatcher ¶
type BodyMatcher struct {
// contains filtered or unexported fields
}
func (BodyMatcher) MarshalJSON ¶
func (bm BodyMatcher) MarshalJSON() ([]byte, error)
func (BodyMatcher) MarshalYAML ¶
func (bm BodyMatcher) MarshalYAML() (interface{}, error)
func (*BodyMatcher) UnmarshalJSON ¶
func (bm *BodyMatcher) UnmarshalJSON(data []byte) error
func (*BodyMatcher) UnmarshalYAML ¶
func (bm *BodyMatcher) UnmarshalYAML(unmarshal func(interface{}) error) error
type Delay ¶
type Delay struct { Min time.Duration `json:"min,omitempty" yaml:"min,omitempty"` Max time.Duration `json:"max,omitempty" yaml:"max,omitempty"` }
func (*Delay) UnmarshalJSON ¶
func (*Delay) UnmarshalYAML ¶
type DynamicMockResponse ¶
type GraphConfig ¶
type GraphEntry ¶
type GraphHistory ¶
type GraphHistory []GraphEntry
func (GraphHistory) Len ¶
func (p GraphHistory) Len() int
func (GraphHistory) Less ¶
func (p GraphHistory) Less(i, j int) bool
func (GraphHistory) Swap ¶
func (p GraphHistory) Swap(i, j int)
type MapStringSlice ¶
type MapStringSlice map[string]StringSlice
type Mock ¶
type Mock struct { Request MockRequest `json:"request,omitempty" yaml:"request"` Response *MockResponse `json:"response,omitempty" yaml:"response,omitempty"` Context *MockContext `json:"context,omitempty" yaml:"context,omitempty"` State *MockState `json:"state,omitempty" yaml:"state,omitempty"` DynamicResponse *DynamicMockResponse `json:"dynamic_response,omitempty" yaml:"dynamic_response,omitempty"` Proxy *MockProxy `json:"proxy,omitempty" yaml:"proxy,omitempty"` }
func (*Mock) CloneAndReset ¶
type MockContext ¶
type MockContext struct {
Times int `json:"times,omitempty" yaml:"times,omitempty"`
}
type MockProxy ¶
type MockProxy struct { Host string `json:"host" yaml:"host"` Delay Delay `json:"delay,omitempty" yaml:"delay,omitempty"` FollowRedirect bool `json:"follow_redirect,omitempty" yaml:"follow_redirect,omitempty"` SkipVerifyTLS bool `json:"skip_verify_tls,omitempty" yaml:"skip_verify_tls,omitempty"` KeepHost bool `json:"keep_host,omitempty" yaml:"keep_host,omitempty"` Headers MapStringSlice `json:"headers,omitempty" yaml:"headers,omitempty"` }
type MockRequest ¶
type MockRequest struct { Path StringMatcher `json:"path" yaml:"path"` Method StringMatcher `json:"method" yaml:"method"` Body *BodyMatcher `json:"body,omitempty" yaml:"body,omitempty"` QueryParams MultiMapMatcher `json:"query_params,omitempty" yaml:"query_params,omitempty"` Headers MultiMapMatcher `json:"headers,omitempty" yaml:"headers,omitempty"` }
func (MockRequest) Match ¶
func (mr MockRequest) Match(req Request) bool
type MockResponse ¶
type MockResponse struct { Body string `json:"body,omitempty" yaml:"body,omitempty"` Status int `json:"status" yaml:"status"` Delay Delay `json:"delay,omitempty" yaml:"delay,omitempty"` Headers MapStringSlice `json:"headers,omitempty" yaml:"headers,omitempty"` }
type MultiMapMatcher ¶
type MultiMapMatcher map[string]StringMatcherSlice
type Request ¶
type Request struct { Path string `json:"path"` Method string `json:"method"` Origin string `json:"origin"` BodyString string `json:"body_string" yaml:"body_string"` Body interface{} `json:"body,omitempty" yaml:"body,omitempty"` QueryParams url.Values `json:"query_params,omitempty" yaml:"query_params,omitempty"` Headers http.Header `json:"headers,omitempty" yaml:"headers,omitempty"` Date time.Time `json:"date" yaml:"date"` }
func HTTPRequestToRequest ¶
type Session ¶
type Session struct { ID string `json:"id"` Name string `json:"name"` Date time.Time `json:"date"` History History `json:"history"` Mocks Mocks `json:"mocks"` }
func (Session) Summarize ¶
func (s Session) Summarize() SessionSummary
type SessionSummary ¶
type Sessions ¶
type Sessions []*Session
func (Sessions) Summarize ¶
func (s Sessions) Summarize() []SessionSummary
type StringMatcher ¶
type StringMatcher struct { Matcher string `json:"matcher" yaml:"matcher,flow"` Value string `json:"value" yaml:"value,flow"` }
func (StringMatcher) Match ¶
func (sm StringMatcher) Match(value string) bool
func (*StringMatcher) UnmarshalJSON ¶
func (sm *StringMatcher) UnmarshalJSON(data []byte) error
func (*StringMatcher) UnmarshalYAML ¶
func (sm *StringMatcher) UnmarshalYAML(unmarshal func(interface{}) error) error
func (StringMatcher) Validate ¶
func (sm StringMatcher) Validate() error
type StringMatcherSlice ¶
type StringMatcherSlice []StringMatcher
func (StringMatcherSlice) Match ¶
func (sms StringMatcherSlice) Match(values []string) bool
func (*StringMatcherSlice) UnmarshalJSON ¶
func (sms *StringMatcherSlice) UnmarshalJSON(data []byte) error
func (*StringMatcherSlice) UnmarshalYAML ¶
func (sms *StringMatcherSlice) UnmarshalYAML(unmarshal func(interface{}) error) error
type StringSlice ¶
type StringSlice []string
StringSlice is a type that can unmarshal a string as a slice string This allows to write a single item slice as a string
func (*StringSlice) UnmarshalJSON ¶
func (ss *StringSlice) UnmarshalJSON(data []byte) error
func (*StringSlice) UnmarshalYAML ¶
func (ss *StringSlice) UnmarshalYAML(unmarshal func(interface{}) error) error
type VerifyResult ¶
type VerifyResult struct { Mocks struct { Verified bool `json:"verified"` AllUsed bool `json:"all_used"` Message string `json:"message"` Failures Mocks `json:"failures,omitempty"` Unused Mocks `json:"unused,omitempty"` } `json:"mocks"` History struct { Verified bool `json:"verified"` Message string `json:"message"` Failures History `json:"failures,omitempty"` } `json:"history"` }
Click to show internal directories.
Click to hide internal directories.