Documentation ¶
Index ¶
- Variables
- func DecodeJSON(r io.Reader, ob interface{}) error
- func NewCloseConnectionHandler(t *testing.T) http.HandlerFunc
- func NewTimeoutHandler(t *testing.T, timeout time.Duration) http.HandlerFunc
- func NewTimeoutHandlerWithClient(t *testing.T, timeouts ...time.Duration) (http.HandlerFunc, *http.Client)
- func WithLayout(layout *capture.Layout) func(*Config)
- func WithPrinter(printer printer) func(*Config)
- func WithWriteFile(basedir string) func(*Config)
- func WithoutCapture() func(*Config)
- type AssertOption
- type Assertion
- type CapturedTransport
- type Config
- type ExtractFacade
- type Facade
- func (f *Facade) Do(req *http.Request, options ...AssertOption) *http.Response
- func (f *Facade) DoHandler(handler http.Handler, req *http.Request, options ...AssertOption) *http.Response
- func (f *Facade) DoHandlerFunc(handler http.HandlerFunc, req *http.Request, options ...AssertOption) *http.Response
- func (f *Facade) Extract() *ExtractFacade
- func (f *Facade) NewJSONRequest(method, url string, body io.Reader) *http.Request
- func (f *Facade) NewRequest(method, url string, body io.Reader) *http.Request
- type HandlerTripper
- type RenderFacade
- type RoundTripFunc
- type TokenAuthorization
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func DecodeJSON ¶
func NewCloseConnectionHandler ¶ added in v0.0.5
func NewCloseConnectionHandler(t *testing.T) http.HandlerFunc
NewCloseConnectionHandler is a handler that closes the connecion suddenly. this is one of the test utilities.
func NewTimeoutHandler ¶ added in v0.0.5
NewTimeoutHandler returns a handler that closes the connecion suddenly. this is one of the test utilities.
func NewTimeoutHandlerWithClient ¶ added in v0.0.5
func NewTimeoutHandlerWithClient(t *testing.T, timeouts ...time.Duration) (http.HandlerFunc, *http.Client)
NewTimeoutHandlerWithClient returns a handler that timeout is occured. this is one of the test utilities.
func WithLayout ¶ added in v0.0.5
func WithPrinter ¶ added in v0.0.5
func WithPrinter(printer printer) func(*Config)
func WithWriteFile ¶ added in v0.0.4
func WithoutCapture ¶ added in v0.0.4
func WithoutCapture() func(*Config)
Types ¶
type AssertOption ¶
type AssertOption func(*Assertion)
func AssertError ¶ added in v0.0.5
func AssertError(handler func(err error) error) AssertOption
func AssertStatus ¶
func AssertStatus(code int) AssertOption
type Assertion ¶
type Assertion struct { StatusCode int Checks []func(t *testing.T, res *http.Response) ExpectError func(err error) error }
func NewAssertion ¶
func NewAssertion() *Assertion
type CapturedTransport ¶
type CapturedTransport struct { T *testing.T Transport http.RoundTripper }
func NewCaptureTransport ¶ added in v0.0.5
func NewCaptureTransport(t *testing.T, transport http.RoundTripper, options ...func(*Config)) *CapturedTransport
func (*CapturedTransport) Capture ¶
func (ct *CapturedTransport) Capture(t *testing.T) func()
func (*CapturedTransport) GetPrefix ¶ added in v0.0.5
func (ct *CapturedTransport) GetPrefix() string
func (*CapturedTransport) Printf ¶ added in v0.0.3
func (ct *CapturedTransport) Printf(fmt string, args ...interface{})
type Config ¶ added in v0.0.5
type Config struct {
// contains filtered or unexported fields
}
func DefaultConfig ¶ added in v0.0.5
func (*Config) NewCaptureTransport ¶ added in v0.0.5
func (c *Config) NewCaptureTransport(transport http.RoundTripper, getPrefix func() string) http.RoundTripper
type ExtractFacade ¶
func (*ExtractFacade) BindJSON ¶ added in v0.0.5
func (f *ExtractFacade) BindJSON(res *http.Response, ob interface{})
func (*ExtractFacade) JSON ¶
func (f *ExtractFacade) JSON(res *http.Response) interface{}
type Facade ¶
type Facade struct { T *testing.T *Config Client *http.Client // contains filtered or unexported fields }
func (*Facade) DoHandlerFunc ¶ added in v0.0.4
func (f *Facade) DoHandlerFunc( handler http.HandlerFunc, req *http.Request, options ...AssertOption, ) *http.Response
func (*Facade) Extract ¶
func (f *Facade) Extract() *ExtractFacade
func (*Facade) NewJSONRequest ¶ added in v0.0.5
type HandlerTripper ¶
type HandlerTripper struct { Before func(*http.Request) Handler http.Handler After func(*http.Response, *http.Request) }
func HandlerTripperFunc ¶
func HandlerTripperFunc(handle func(w http.ResponseWriter, r *http.Request)) *HandlerTripper
type RenderFacade ¶
type RenderFacade struct {
// contains filtered or unexported fields
}
func NewRender ¶ added in v0.0.5
func NewRender(w http.ResponseWriter, r *http.Request) *RenderFacade
func Render ¶
func Render(w http.ResponseWriter, r *http.Request) *RenderFacade
func (*RenderFacade) JSON ¶
func (f *RenderFacade) JSON(code int, v interface{})
func (*RenderFacade) JSONArray ¶
func (f *RenderFacade) JSONArray(code int, v interface{})
func (*RenderFacade) SetNGStatus ¶
func (f *RenderFacade) SetNGStatus(code int) *RenderFacade
type RoundTripFunc ¶
func NewErrorTransport ¶ added in v0.0.5
func NewErrorTransport(t *testing.T, genErr func() error) RoundTripFunc
NewErrorTransport returns a transport that returns error. this is one of the test utilities.
type TokenAuthorization ¶ added in v0.0.5
type TokenAuthorization struct {
Token string
}
func (*TokenAuthorization) Apply ¶ added in v0.0.5
func (a *TokenAuthorization) Apply(req *http.Request)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.