Documentation ¶
Index ¶
- Constants
- type Definition
- type Error
- type Loader
- type Mocks
- func (m *Mocks) EndRunningContext() []error
- func (m *Mocks) GetNames() []string
- func (m *Mocks) ResetDefinitions()
- func (m *Mocks) ResetRunningContext()
- func (m *Mocks) Service(serviceName string) *ServiceMock
- func (m *Mocks) SetMock(mock *ServiceMock)
- func (m *Mocks) Shutdown()
- func (m *Mocks) ShutdownContext(ctx context.Context) error
- func (m *Mocks) Start() error
- type ReplyStrategy
- func NewConstantReplyWithCode(content []byte, statusCode int, headers map[string]string) ReplyStrategy
- func NewDropRequestReply() ReplyStrategy
- func NewFileReplyWithCode(filename string, statusCode int, headers map[string]string) (ReplyStrategy, error)
- func NewMethodVaryReply(variants map[string]*Definition) ReplyStrategy
- func NewSequentialReply(strategies []*Definition) ReplyStrategy
- func NewUriVaryReply(basePath string, variants map[string]*Definition) ReplyStrategy
- type RequestConstraintError
- type ServiceMock
- func (m *ServiceMock) EndRunningContext() []error
- func (m *ServiceMock) ResetDefinition()
- func (m *ServiceMock) ResetRunningContext()
- func (m *ServiceMock) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (m *ServiceMock) ServerAddr() string
- func (m *ServiceMock) SetDefinition(newDefinition *Definition)
- func (m *ServiceMock) ShutdownServer(ctx context.Context) error
- func (m *ServiceMock) StartServer() error
- func (m *ServiceMock) StartServerWithAddr(addr string) error
Constants ¶
View Source
const CallsNoConstraint = -1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Definition ¶
type Definition struct {
// contains filtered or unexported fields
}
func NewDefinition ¶
func NewDefinition(path string, constraints []verifier, strategy ReplyStrategy, callsConstraint int) *Definition
func (*Definition) EndRunningContext ¶
func (d *Definition) EndRunningContext() []error
func (*Definition) Execute ¶
func (d *Definition) Execute(w http.ResponseWriter, r *http.Request) []error
func (*Definition) ExecuteWithoutVerifying ¶
func (d *Definition) ExecuteWithoutVerifying(w http.ResponseWriter, r *http.Request) []error
func (*Definition) ResetRunningContext ¶
func (d *Definition) ResetRunningContext()
type Mocks ¶
type Mocks struct {
// contains filtered or unexported fields
}
func New ¶
func New(mocks ...*ServiceMock) *Mocks
func (*Mocks) EndRunningContext ¶
func (*Mocks) ResetDefinitions ¶
func (m *Mocks) ResetDefinitions()
func (*Mocks) ResetRunningContext ¶
func (m *Mocks) ResetRunningContext()
func (*Mocks) Service ¶
func (m *Mocks) Service(serviceName string) *ServiceMock
func (*Mocks) SetMock ¶
func (m *Mocks) SetMock(mock *ServiceMock)
type ReplyStrategy ¶
type ReplyStrategy interface {
HandleRequest(w http.ResponseWriter, r *http.Request) []error
}
func NewConstantReplyWithCode ¶
func NewConstantReplyWithCode(content []byte, statusCode int, headers map[string]string) ReplyStrategy
func NewDropRequestReply ¶
func NewDropRequestReply() ReplyStrategy
func NewFileReplyWithCode ¶
func NewMethodVaryReply ¶
func NewMethodVaryReply(variants map[string]*Definition) ReplyStrategy
func NewSequentialReply ¶
func NewSequentialReply(strategies []*Definition) ReplyStrategy
func NewUriVaryReply ¶
func NewUriVaryReply(basePath string, variants map[string]*Definition) ReplyStrategy
type RequestConstraintError ¶
type RequestConstraintError struct { Constraint verifier RequestDump []byte // contains filtered or unexported fields }
func (*RequestConstraintError) Error ¶
func (e *RequestConstraintError) Error() string
type ServiceMock ¶
type ServiceMock struct { sync.RWMutex ServiceName string // contains filtered or unexported fields }
func NewServiceMock ¶
func NewServiceMock(serviceName string, mock *Definition) *ServiceMock
func (*ServiceMock) EndRunningContext ¶
func (m *ServiceMock) EndRunningContext() []error
func (*ServiceMock) ResetDefinition ¶
func (m *ServiceMock) ResetDefinition()
func (*ServiceMock) ResetRunningContext ¶
func (m *ServiceMock) ResetRunningContext()
func (*ServiceMock) ServeHTTP ¶
func (m *ServiceMock) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*ServiceMock) ServerAddr ¶
func (m *ServiceMock) ServerAddr() string
func (*ServiceMock) SetDefinition ¶
func (m *ServiceMock) SetDefinition(newDefinition *Definition)
func (*ServiceMock) ShutdownServer ¶
func (m *ServiceMock) ShutdownServer(ctx context.Context) error
func (*ServiceMock) StartServer ¶
func (m *ServiceMock) StartServer() error
func (*ServiceMock) StartServerWithAddr ¶
func (m *ServiceMock) StartServerWithAddr(addr string) error
Click to show internal directories.
Click to hide internal directories.