Documentation
¶
Index ¶
Constants ¶
View Source
const ( // ContentTypeHeader is the content type header ContentTypeHeader = "Content-Type" // ContentTypeJSON is the content type for json ContentTypeJSON = "application/json" )
View Source
const ( // RootPath is the root path for Response Json call RootPath string = "" )
Variables ¶
This section is empty.
Functions ¶
func NewReadCloser ¶ added in v0.6.0
func NewReadCloser(r io.Reader) io.ReadCloser
NewReadCloser creates a new readCloser wrapping the given io.Reader
Types ¶
type APIClient ¶
type APIClient interface {
// Delete does a DELETE response to the APIClient
Delete(t require.TestingT, path string) APIRequest
// Get does a GET response to the APIClient
Get(t require.TestingT, path string) APIRequest
// Post does a POST response to the APIClient
Post(t require.TestingT, path string) APIRequest
// Put does a PUT response to the APIClient
Put(t require.TestingT, path string) APIRequest
// Request does a response to the APIClient
Request(t require.TestingT, method string, path string) APIRequest
// ReverseURL creates a path by given url name and url arguments
ReverseURL(t require.TestingT, name string, extra ...resolver.Extra) string
// ReverseArgs creates a resolver.Extra from given key value pairs
ReverseArgs(t require.TestingT, kv ...string) resolver.Extra
// ReverseQuery creates a resolver.Extra from given key value pairs
ReverseQuery(t require.TestingT, kv ...string) resolver.Extra
}
APIClient is the interface for testing the rest APIClient
type APIRequest ¶
type APIRequest interface {
// Body sets the body of the request
Body(t require.TestingT, body any) APIRequest
// Do perform the request and returns the response
Do(t require.TestingT, ctx context.Context) APIResponse
// Header sets the header of the request
Header(t require.TestingT, key, value string) APIRequest
// Print the response to stdout
Print(writer ...io.Writer) APIRequest
// Query sets the query of the request
Query(t require.TestingT, key, value string) APIRequest
}
APIRequest is the interface for testing the rest APIClient response
type APIResponse ¶
type APIResponse interface {
// Print the response to stdout
Print(writer ...io.Writer) APIResponse
// Header asserts that response header action is equal to given action
Header(t require.TestingT, key string, action action.Action) APIResponse
// Json calls the action on the json response path
Json(t require.TestingT, path string, action action.Action) APIResponse
// Status asserts that response status is equal to given action
Status(t require.TestingT, action action.Action) APIResponse
}
APIResponse is the interface for testing the rest APIClient response
type Deps ¶
type Deps struct {
// Handler is the http.Handler
Handler http.Handler
// Addr is the address of the server (host:port)
Address string
// Client sets custom http client
Client *http.Client
// Resolver is the URL resolver
Resolver resolver.Resolver
}
Deps is the dependencies for the APIClient Resolve provides ReverseURL method, but is only optional One of Handler or Address is required
func (*Deps) ReverseArgs ¶ added in v0.5.0
ReverseArgs adds arguments key action pairs to resolver.Extra for ReverseURL
func (*Deps) ReverseQuery ¶ added in v0.5.0
ReverseQuery adds query key action pairs to resolver.Extra for ReverseURL
func (*Deps) ReverseURL ¶ added in v0.5.0
ReverseURL resolves URL by name
type RoundTripper ¶ added in v0.5.0
type RoundTripper interface {
http.RoundTripper
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.