Documentation
¶
Overview ¶
Package apitest drives the API in handler tests the way a same-origin browser would.
Index ¶
- func Decode[T any](t *testing.T, rec *httptest.ResponseRecorder) T
- func ErrorOf(t *testing.T, rec *httptest.ResponseRecorder) web.APIError
- func NewEcho() *echo.Echo
- type Client
- func (c *Client) As(cookie *http.Cookie) *Client
- func (c *Client) Do(t *testing.T, req *http.Request) *httptest.ResponseRecorder
- func (c *Client) Get(t *testing.T, path string) *httptest.ResponseRecorder
- func (c *Client) JSON(t *testing.T, method, path string, body any) *httptest.ResponseRecorder
- func (c *Client) Multipart(t *testing.T, method, path string, fields map[string]string, files ...FilePart) *httptest.ResponseRecorder
- type FilePart
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
func Decode[T any](t *testing.T, rec *httptest.ResponseRecorder) T
Decode unmarshals the response body into T.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client sends requests to an Echo instance, optionally with a session cookie.
Click to show internal directories.
Click to hide internal directories.