Documentation ¶
Overview ¶
Package hooks implements event listeners for mocha internal actions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
Emitter implements a event listener, subscriber and emitter.
func NewEmitter ¶
NewEmitter creates an Emitter instance.
type Events ¶
type Events interface { OnRequest(OnRequest) OnRequestMatched(OnRequestMatch) OnRequestNotMatched(OnRequestNotMatched) OnError(OnError) }
Events interface defines available event handlers.
type InternalEvents ¶
type InternalEvents struct {
// contains filtered or unexported fields
}
InternalEvents implements default event handlers that logs event information.
func NewInternalEvents ¶
func NewInternalEvents(l Logger) *InternalEvents
NewInternalEvents creates an internal event handlers.
func (*InternalEvents) OnError ¶
func (h *InternalEvents) OnError(e OnError)
func (*InternalEvents) OnRequest ¶
func (h *InternalEvents) OnRequest(e OnRequest)
func (*InternalEvents) OnRequestMatched ¶
func (h *InternalEvents) OnRequestMatched(e OnRequestMatch)
func (*InternalEvents) OnRequestNotMatched ¶
func (h *InternalEvents) OnRequestNotMatched(e OnRequestNotMatched)
type OnRequestMatch ¶
type OnRequestMatch struct { Request Request ResponseDefinition Response Mock Mock Elapsed time.Duration }
OnRequestMatch event is triggered when a mock is found for a request.
type OnRequestNotMatched ¶
OnRequestNotMatched event is triggered when no mocks are found for a request.
type Request ¶
Request defines information from http.Request to be logged.
func FromRequest ¶
FromRequest is a helper function that creates a new Request from a http.Request.
type Result ¶
type Result struct { HasClosestMatch bool ClosestMatch Mock Details []ResultDetail }
Result defines matching result to be logged.
type ResultDetail ¶
ResultDetail defines matching result details to be logged.