Documentation
¶
Index ¶
- Variables
- func GetClientIP(req *http.Request) string
- type Endpoint
- type EndpointsInvocation
- type FakeResponse
- func (f *FakeResponse) AssertHeaderCalled(t *testing.T)
- func (f *FakeResponse) AssertHeaderCalledN(t *testing.T, n int)
- func (f *FakeResponse) AssertHeaderCalledOnce(t *testing.T)
- func (f *FakeResponse) AssertHeaderNotCalled(t *testing.T)
- func (f *FakeResponse) AssertSerializeCalled(t *testing.T)
- func (f *FakeResponse) AssertSerializeCalledN(t *testing.T, n int)
- func (f *FakeResponse) AssertSerializeCalledOnce(t *testing.T)
- func (_f8 *FakeResponse) AssertSerializeCalledOnceWith(t *testing.T, ident62 io.Writer)
- func (_f6 *FakeResponse) AssertSerializeCalledWith(t *testing.T, ident62 io.Writer)
- func (f *FakeResponse) AssertSerializeNotCalled(t *testing.T)
- func (f *FakeResponse) AssertStatusCodeCalled(t *testing.T)
- func (f *FakeResponse) AssertStatusCodeCalledN(t *testing.T, n int)
- func (f *FakeResponse) AssertStatusCodeCalledOnce(t *testing.T)
- func (f *FakeResponse) AssertStatusCodeNotCalled(t *testing.T)
- func (f *FakeResponse) AssertTrailerCalled(t *testing.T)
- func (f *FakeResponse) AssertTrailerCalledN(t *testing.T, n int)
- func (f *FakeResponse) AssertTrailerCalledOnce(t *testing.T)
- func (f *FakeResponse) AssertTrailerNotCalled(t *testing.T)
- func (_f2 *FakeResponse) Header() (ident60 http.Header)
- func (f *FakeResponse) HeaderCalled() bool
- func (f *FakeResponse) HeaderCalledN(n int) bool
- func (f *FakeResponse) HeaderCalledOnce() bool
- func (f *FakeResponse) HeaderNotCalled() bool
- func (_f4 *FakeResponse) Serialize(ident62 io.Writer) (ident63 error)
- func (f *FakeResponse) SerializeCalled() bool
- func (f *FakeResponse) SerializeCalledN(n int) bool
- func (f *FakeResponse) SerializeCalledOnce() bool
- func (_f7 *FakeResponse) SerializeCalledOnceWith(ident62 io.Writer) bool
- func (_f5 *FakeResponse) SerializeCalledWith(ident62 io.Writer) (found bool)
- func (f *FakeResponse) SerializeNotCalled() bool
- func (_f9 *FakeResponse) SerializeResultsForCall(ident62 io.Writer) (ident63 error, found bool)
- func (_f1 *FakeResponse) StatusCode() (ident59 int)
- func (f *FakeResponse) StatusCodeCalled() bool
- func (f *FakeResponse) StatusCodeCalledN(n int) bool
- func (f *FakeResponse) StatusCodeCalledOnce() bool
- func (f *FakeResponse) StatusCodeNotCalled() bool
- func (_f3 *FakeResponse) Trailer() (ident61 http.Header)
- func (f *FakeResponse) TrailerCalled() bool
- func (f *FakeResponse) TrailerCalledN(n int) bool
- func (f *FakeResponse) TrailerCalledOnce() bool
- func (f *FakeResponse) TrailerNotCalled() bool
- type FakeService
- func (f *FakeService) AssertEndpointsCalled(t *testing.T)
- func (f *FakeService) AssertEndpointsCalledN(t *testing.T, n int)
- func (f *FakeService) AssertEndpointsCalledOnce(t *testing.T)
- func (f *FakeService) AssertEndpointsNotCalled(t *testing.T)
- func (f *FakeService) AssertNameCalled(t *testing.T)
- func (f *FakeService) AssertNameCalledN(t *testing.T, n int)
- func (f *FakeService) AssertNameCalledOnce(t *testing.T)
- func (f *FakeService) AssertNameNotCalled(t *testing.T)
- func (_f2 *FakeService) Endpoints() (ident102 []Endpoint)
- func (f *FakeService) EndpointsCalled() bool
- func (f *FakeService) EndpointsCalledN(n int) bool
- func (f *FakeService) EndpointsCalledOnce() bool
- func (f *FakeService) EndpointsNotCalled() bool
- func (_f1 *FakeService) Name() (ident101 string)
- func (f *FakeService) NameCalled() bool
- func (f *FakeService) NameCalledN(n int) bool
- func (f *FakeService) NameCalledOnce() bool
- func (f *FakeService) NameNotCalled() bool
- type Handler
- type HeaderInvocation
- type NameInvocation
- type Pipeline
- type Policy
- type Request
- func (r *Request) GenerateID() string
- func (r *Request) PathArg(name string) (string, bool)
- func (r *Request) PathArgInt(name string) (int, error)
- func (r *Request) QueryParam(name string) (string, bool)
- func (r *Request) QueryParamBool(name string) (bool, bool)
- func (r *Request) QueryParamExists(name string) bool
- func (r *Request) QueryParamInt(name string) (int, error)
- func (r *Request) QueryParamUint(name string) (uint, error)
- type Response
- type SerializeInvocation
- type Service
- type StatusCodeInvocation
- type TrailerInvocation
Constants ¶
This section is empty.
Variables ¶
var (
ParameterNotPresented = errors.New("parameter not presented")
)
Functions ¶
func GetClientIP ¶
Types ¶
type EndpointsInvocation ¶
type EndpointsInvocation struct {
Results struct {
Ident102 []Endpoint
}
}
EndpointsInvocation represents a single call of FakeService.Endpoints
type FakeResponse ¶
type FakeResponse struct {
StatusCodeHook func() int
HeaderHook func() http.Header
TrailerHook func() http.Header
SerializeHook func(io.Writer) error
StatusCodeCalls []*StatusCodeInvocation
HeaderCalls []*HeaderInvocation
TrailerCalls []*TrailerInvocation
SerializeCalls []*SerializeInvocation
}
FakeResponse is a mock implementation of Response for testing. Use it in your tests as in this example:
package example
func TestWithResponse(t *testing.T) {
f := &service.FakeResponse{
StatusCodeHook: func() (ident59 int) {
// ensure parameters meet expections, signal errors using t, etc
return
},
}
// test code goes here ...
// assert state of FakeStatusCode ...
f.AssertStatusCodeCalledOnce(t)
}
Create anonymous function implementations for only those interface methods that should be called in the code under test. This will force a panic if any unexpected calls are made to FakeStatusCode.
func NewFakeResponseDefaultError ¶
func NewFakeResponseDefaultError(t *testing.T) *FakeResponse
NewFakeResponseDefaultError returns an instance of FakeResponse with all hooks configured to call t.Error
func NewFakeResponseDefaultFatal ¶
func NewFakeResponseDefaultFatal(t *testing.T) *FakeResponse
NewFakeResponseDefaultFatal returns an instance of FakeResponse with all hooks configured to call t.Fatal
func NewFakeResponseDefaultPanic ¶
func NewFakeResponseDefaultPanic() *FakeResponse
NewFakeResponseDefaultPanic returns an instance of FakeResponse with all hooks configured to panic
func (*FakeResponse) AssertHeaderCalled ¶
func (f *FakeResponse) AssertHeaderCalled(t *testing.T)
AssertHeaderCalled calls t.Error if FakeResponse.Header was not called
func (*FakeResponse) AssertHeaderCalledN ¶
func (f *FakeResponse) AssertHeaderCalledN(t *testing.T, n int)
AssertHeaderCalledN calls t.Error if FakeResponse.Header was called less than n times
func (*FakeResponse) AssertHeaderCalledOnce ¶
func (f *FakeResponse) AssertHeaderCalledOnce(t *testing.T)
AssertHeaderCalledOnce calls t.Error if FakeResponse.Header was not called exactly once
func (*FakeResponse) AssertHeaderNotCalled ¶
func (f *FakeResponse) AssertHeaderNotCalled(t *testing.T)
AssertHeaderNotCalled calls t.Error if FakeResponse.Header was called
func (*FakeResponse) AssertSerializeCalled ¶
func (f *FakeResponse) AssertSerializeCalled(t *testing.T)
AssertSerializeCalled calls t.Error if FakeResponse.Serialize was not called
func (*FakeResponse) AssertSerializeCalledN ¶
func (f *FakeResponse) AssertSerializeCalledN(t *testing.T, n int)
AssertSerializeCalledN calls t.Error if FakeResponse.Serialize was called less than n times
func (*FakeResponse) AssertSerializeCalledOnce ¶
func (f *FakeResponse) AssertSerializeCalledOnce(t *testing.T)
AssertSerializeCalledOnce calls t.Error if FakeResponse.Serialize was not called exactly once
func (*FakeResponse) AssertSerializeCalledOnceWith ¶
func (_f8 *FakeResponse) AssertSerializeCalledOnceWith(t *testing.T, ident62 io.Writer)
AssertSerializeCalledOnceWith calls t.Error if FakeResponse.Serialize was not called exactly once with the given values
func (*FakeResponse) AssertSerializeCalledWith ¶
func (_f6 *FakeResponse) AssertSerializeCalledWith(t *testing.T, ident62 io.Writer)
AssertSerializeCalledWith calls t.Error if FakeResponse.Serialize was not called with the given values
func (*FakeResponse) AssertSerializeNotCalled ¶
func (f *FakeResponse) AssertSerializeNotCalled(t *testing.T)
AssertSerializeNotCalled calls t.Error if FakeResponse.Serialize was called
func (*FakeResponse) AssertStatusCodeCalled ¶
func (f *FakeResponse) AssertStatusCodeCalled(t *testing.T)
AssertStatusCodeCalled calls t.Error if FakeResponse.StatusCode was not called
func (*FakeResponse) AssertStatusCodeCalledN ¶
func (f *FakeResponse) AssertStatusCodeCalledN(t *testing.T, n int)
AssertStatusCodeCalledN calls t.Error if FakeResponse.StatusCode was called less than n times
func (*FakeResponse) AssertStatusCodeCalledOnce ¶
func (f *FakeResponse) AssertStatusCodeCalledOnce(t *testing.T)
AssertStatusCodeCalledOnce calls t.Error if FakeResponse.StatusCode was not called exactly once
func (*FakeResponse) AssertStatusCodeNotCalled ¶
func (f *FakeResponse) AssertStatusCodeNotCalled(t *testing.T)
AssertStatusCodeNotCalled calls t.Error if FakeResponse.StatusCode was called
func (*FakeResponse) AssertTrailerCalled ¶
func (f *FakeResponse) AssertTrailerCalled(t *testing.T)
AssertTrailerCalled calls t.Error if FakeResponse.Trailer was not called
func (*FakeResponse) AssertTrailerCalledN ¶
func (f *FakeResponse) AssertTrailerCalledN(t *testing.T, n int)
AssertTrailerCalledN calls t.Error if FakeResponse.Trailer was called less than n times
func (*FakeResponse) AssertTrailerCalledOnce ¶
func (f *FakeResponse) AssertTrailerCalledOnce(t *testing.T)
AssertTrailerCalledOnce calls t.Error if FakeResponse.Trailer was not called exactly once
func (*FakeResponse) AssertTrailerNotCalled ¶
func (f *FakeResponse) AssertTrailerNotCalled(t *testing.T)
AssertTrailerNotCalled calls t.Error if FakeResponse.Trailer was called
func (*FakeResponse) Header ¶
func (_f2 *FakeResponse) Header() (ident60 http.Header)
func (*FakeResponse) HeaderCalled ¶
func (f *FakeResponse) HeaderCalled() bool
HeaderCalled returns true if FakeResponse.Header was called
func (*FakeResponse) HeaderCalledN ¶
func (f *FakeResponse) HeaderCalledN(n int) bool
HeaderCalledN returns true if FakeResponse.Header was called at least n times
func (*FakeResponse) HeaderCalledOnce ¶
func (f *FakeResponse) HeaderCalledOnce() bool
HeaderCalledOnce returns true if FakeResponse.Header was called exactly once
func (*FakeResponse) HeaderNotCalled ¶
func (f *FakeResponse) HeaderNotCalled() bool
HeaderNotCalled returns true if FakeResponse.Header was not called
func (*FakeResponse) Serialize ¶
func (_f4 *FakeResponse) Serialize(ident62 io.Writer) (ident63 error)
func (*FakeResponse) SerializeCalled ¶
func (f *FakeResponse) SerializeCalled() bool
SerializeCalled returns true if FakeResponse.Serialize was called
func (*FakeResponse) SerializeCalledN ¶
func (f *FakeResponse) SerializeCalledN(n int) bool
SerializeCalledN returns true if FakeResponse.Serialize was called at least n times
func (*FakeResponse) SerializeCalledOnce ¶
func (f *FakeResponse) SerializeCalledOnce() bool
SerializeCalledOnce returns true if FakeResponse.Serialize was called exactly once
func (*FakeResponse) SerializeCalledOnceWith ¶
func (_f7 *FakeResponse) SerializeCalledOnceWith(ident62 io.Writer) bool
SerializeCalledOnceWith returns true if FakeResponse.Serialize was called exactly once with the given values
func (*FakeResponse) SerializeCalledWith ¶
func (_f5 *FakeResponse) SerializeCalledWith(ident62 io.Writer) (found bool)
SerializeCalledWith returns true if FakeResponse.Serialize was called with the given values
func (*FakeResponse) SerializeNotCalled ¶
func (f *FakeResponse) SerializeNotCalled() bool
SerializeNotCalled returns true if FakeResponse.Serialize was not called
func (*FakeResponse) SerializeResultsForCall ¶
func (_f9 *FakeResponse) SerializeResultsForCall(ident62 io.Writer) (ident63 error, found bool)
SerializeResultsForCall returns the result values for the first call to FakeResponse.Serialize with the given values
func (*FakeResponse) StatusCode ¶
func (_f1 *FakeResponse) StatusCode() (ident59 int)
func (*FakeResponse) StatusCodeCalled ¶
func (f *FakeResponse) StatusCodeCalled() bool
StatusCodeCalled returns true if FakeResponse.StatusCode was called
func (*FakeResponse) StatusCodeCalledN ¶
func (f *FakeResponse) StatusCodeCalledN(n int) bool
StatusCodeCalledN returns true if FakeResponse.StatusCode was called at least n times
func (*FakeResponse) StatusCodeCalledOnce ¶
func (f *FakeResponse) StatusCodeCalledOnce() bool
StatusCodeCalledOnce returns true if FakeResponse.StatusCode was called exactly once
func (*FakeResponse) StatusCodeNotCalled ¶
func (f *FakeResponse) StatusCodeNotCalled() bool
StatusCodeNotCalled returns true if FakeResponse.StatusCode was not called
func (*FakeResponse) Trailer ¶
func (_f3 *FakeResponse) Trailer() (ident61 http.Header)
func (*FakeResponse) TrailerCalled ¶
func (f *FakeResponse) TrailerCalled() bool
TrailerCalled returns true if FakeResponse.Trailer was called
func (*FakeResponse) TrailerCalledN ¶
func (f *FakeResponse) TrailerCalledN(n int) bool
TrailerCalledN returns true if FakeResponse.Trailer was called at least n times
func (*FakeResponse) TrailerCalledOnce ¶
func (f *FakeResponse) TrailerCalledOnce() bool
TrailerCalledOnce returns true if FakeResponse.Trailer was called exactly once
func (*FakeResponse) TrailerNotCalled ¶
func (f *FakeResponse) TrailerNotCalled() bool
TrailerNotCalled returns true if FakeResponse.Trailer was not called
type FakeService ¶
type FakeService struct {
NameHook func() string
EndpointsHook func() []Endpoint
NameCalls []*NameInvocation
EndpointsCalls []*EndpointsInvocation
}
FakeService is a mock implementation of Service for testing. Use it in your tests as in this example:
package example
func TestWithService(t *testing.T) {
f := &service.FakeService{
NameHook: func() (ident101 string) {
// ensure parameters meet expections, signal errors using t, etc
return
},
}
// test code goes here ...
// assert state of FakeName ...
f.AssertNameCalledOnce(t)
}
Create anonymous function implementations for only those interface methods that should be called in the code under test. This will force a panic if any unexpected calls are made to FakeName.
func NewFakeServiceDefaultError ¶
func NewFakeServiceDefaultError(t *testing.T) *FakeService
NewFakeServiceDefaultError returns an instance of FakeService with all hooks configured to call t.Error
func NewFakeServiceDefaultFatal ¶
func NewFakeServiceDefaultFatal(t *testing.T) *FakeService
NewFakeServiceDefaultFatal returns an instance of FakeService with all hooks configured to call t.Fatal
func NewFakeServiceDefaultPanic ¶
func NewFakeServiceDefaultPanic() *FakeService
NewFakeServiceDefaultPanic returns an instance of FakeService with all hooks configured to panic
func (*FakeService) AssertEndpointsCalled ¶
func (f *FakeService) AssertEndpointsCalled(t *testing.T)
AssertEndpointsCalled calls t.Error if FakeService.Endpoints was not called
func (*FakeService) AssertEndpointsCalledN ¶
func (f *FakeService) AssertEndpointsCalledN(t *testing.T, n int)
AssertEndpointsCalledN calls t.Error if FakeService.Endpoints was called less than n times
func (*FakeService) AssertEndpointsCalledOnce ¶
func (f *FakeService) AssertEndpointsCalledOnce(t *testing.T)
AssertEndpointsCalledOnce calls t.Error if FakeService.Endpoints was not called exactly once
func (*FakeService) AssertEndpointsNotCalled ¶
func (f *FakeService) AssertEndpointsNotCalled(t *testing.T)
AssertEndpointsNotCalled calls t.Error if FakeService.Endpoints was called
func (*FakeService) AssertNameCalled ¶
func (f *FakeService) AssertNameCalled(t *testing.T)
AssertNameCalled calls t.Error if FakeService.Name was not called
func (*FakeService) AssertNameCalledN ¶
func (f *FakeService) AssertNameCalledN(t *testing.T, n int)
AssertNameCalledN calls t.Error if FakeService.Name was called less than n times
func (*FakeService) AssertNameCalledOnce ¶
func (f *FakeService) AssertNameCalledOnce(t *testing.T)
AssertNameCalledOnce calls t.Error if FakeService.Name was not called exactly once
func (*FakeService) AssertNameNotCalled ¶
func (f *FakeService) AssertNameNotCalled(t *testing.T)
AssertNameNotCalled calls t.Error if FakeService.Name was called
func (*FakeService) Endpoints ¶
func (_f2 *FakeService) Endpoints() (ident102 []Endpoint)
func (*FakeService) EndpointsCalled ¶
func (f *FakeService) EndpointsCalled() bool
EndpointsCalled returns true if FakeService.Endpoints was called
func (*FakeService) EndpointsCalledN ¶
func (f *FakeService) EndpointsCalledN(n int) bool
EndpointsCalledN returns true if FakeService.Endpoints was called at least n times
func (*FakeService) EndpointsCalledOnce ¶
func (f *FakeService) EndpointsCalledOnce() bool
EndpointsCalledOnce returns true if FakeService.Endpoints was called exactly once
func (*FakeService) EndpointsNotCalled ¶
func (f *FakeService) EndpointsNotCalled() bool
EndpointsNotCalled returns true if FakeService.Endpoints was not called
func (*FakeService) Name ¶
func (_f1 *FakeService) Name() (ident101 string)
func (*FakeService) NameCalled ¶
func (f *FakeService) NameCalled() bool
NameCalled returns true if FakeService.Name was called
func (*FakeService) NameCalledN ¶
func (f *FakeService) NameCalledN(n int) bool
NameCalledN returns true if FakeService.Name was called at least n times
func (*FakeService) NameCalledOnce ¶
func (f *FakeService) NameCalledOnce() bool
NameCalledOnce returns true if FakeService.Name was called exactly once
func (*FakeService) NameNotCalled ¶
func (f *FakeService) NameNotCalled() bool
NameNotCalled returns true if FakeService.Name was not called
type HeaderInvocation ¶
HeaderInvocation represents a single call of FakeResponse.Header
type NameInvocation ¶
type NameInvocation struct {
Results struct {
Ident101 string
}
}
NameInvocation represents a single call of FakeService.Name
type Policy ¶
type Policy struct {
AllowUnknownQueryParameters bool // will unknown query parameters be silently ignored?
AllowMalformedQueryParameters bool // will malformed query parameter pairs be silently ignored?
CustomMalformedRequestStatus int // this status code will be returned instead of 400 on malformed requests
RequestBudget time.Duration // the time budget for requests to the endpoint
GenerateRequestID bool // should a request id be generated automatically?
}
Policy controls the behavior of per-endpoint request processing before control is passed to the handler.
type Response ¶
type SerializeInvocation ¶
type SerializeInvocation struct {
Parameters struct {
Ident62 io.Writer
}
Results struct {
Ident63 error
}
}
SerializeInvocation represents a single call of FakeResponse.Serialize
type StatusCodeInvocation ¶
type StatusCodeInvocation struct {
Results struct {
Ident59 int
}
}
StatusCodeInvocation represents a single call of FakeResponse.StatusCode
type TrailerInvocation ¶
TrailerInvocation represents a single call of FakeResponse.Trailer