Documentation ¶
Index ¶
- func Crypter(t *testing.T) crypter.Crypter
- func DELETE(t *testing.T, svr http.Handler, addr string, body io.Reader, ...)
- func DecodeBody(t *testing.T, r io.Reader, v interface{})
- func Do(t *testing.T, method, addr string, body io.Reader) *http.Response
- func EncodeBody(t *testing.T, v interface{}) *bytes.Buffer
- func GET(t *testing.T, svr http.Handler, addr string, assertFns ...RecTestFn)
- func GetURL(t *testing.T, addr string) *url.URL
- func HEAD(t *testing.T, svr http.Handler, addr string, assertFns ...RecTestFn)
- func HTTP(t *testing.T, svr http.Handler, method, addr string, body io.Reader, ...)
- func JSONPrettyPrint(t *testing.T, v interface{})
- func NewRandomPort(t *testing.T) (string, string)
- func PATCH(t *testing.T, svr http.Handler, addr string, body io.Reader, ...)
- func POST(t *testing.T, svr http.Handler, addr string, body io.Reader, ...)
- func PUT(t *testing.T, svr http.Handler, addr string, body io.Reader, ...)
- type RecTestFn
- func ContentType(contentType string) RecTestFn
- func Header(key, val string) RecTestFn
- func Resp(assertFn func(t *testing.T, w *httptest.ResponseRecorder)) RecTestFn
- func Status(status int) RecTestFn
- func StatusAccepted() RecTestFn
- func StatusBadRequest() RecTestFn
- func StatusCreated() RecTestFn
- func StatusInternalServerError() RecTestFn
- func StatusNoContent() RecTestFn
- func StatusNotFound() RecTestFn
- func StatusNotImplemented() RecTestFn
- func StatusOK() RecTestFn
- func StatusUnprocessableEntity() RecTestFn
- type WorkDir
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeBody ¶
DecodeBody is a helper for decoding an io.reader (i.e. response body) into the destination type (v).
func EncodeBody ¶
EncodeBody is a helper func for encoding a type into an bytes.Buffer type. Can be used for a response body or whatever else. The returned buffer can be written or read from as needed.
func HTTP ¶
func HTTP( t *testing.T, svr http.Handler, method, addr string, body io.Reader, assertFns ...RecTestFn, )
HTTP is a test utility to test a svr handles whatever call you provide it.
func JSONPrettyPrint ¶
JSONPrettyPrint pretty prints a json body in all its glory.
func NewRandomPort ¶
NewRandomPort identifies a port on the localhost interface for use during tests and returns the string in host:port format as well as a url with an http scheme. It uses similar methodology to how the net/http/httptest server chooses a port.
Types ¶
type RecTestFn ¶
type RecTestFn func(t *testing.T, w *httptest.ResponseRecorder)
RecTestFn is a functional option to run assertions against the response of the http request being made by the HTTP func or its relatives.
func ContentType ¶
ContentType verifies that the Content-Type of the response matches the contentType provided.
func Resp ¶
func Resp(assertFn func(t *testing.T, w *httptest.ResponseRecorder)) RecTestFn
Resp allows the body to be asserted and viewed per the function.
func StatusAccepted ¶
func StatusAccepted() RecTestFn
StatusAccepted verifies the status code is 202 (Status Accepted).
func StatusBadRequest ¶
func StatusBadRequest() RecTestFn
StatusBadRequest verifies the sttus code is 400 (Bad Request).
func StatusCreated ¶
func StatusCreated() RecTestFn
StatusCreated verifies the status code is 201 (Status Created).
func StatusInternalServerError ¶
func StatusInternalServerError() RecTestFn
StatusInternalServerError verifies the status code is 500 (Status Internal Server Error).
func StatusNoContent ¶
func StatusNoContent() RecTestFn
StatusNoContent verifies the status code is 204 (Status No Content).
func StatusNotFound ¶
func StatusNotFound() RecTestFn
StatusNotFound verifies the status code is 404 (Status Not Found).
func StatusNotImplemented ¶
func StatusNotImplemented() RecTestFn
StatusNotImplemented verifies the status code is 501 (Status Not Implemented).
func StatusUnprocessableEntity ¶
func StatusUnprocessableEntity() RecTestFn
StatusUnprocessableEntity verifies the status code is 422 (Status Unprocessable Entity).
type WorkDir ¶
type WorkDir struct {
// contains filtered or unexported fields
}
WorkDir creates a new temporary working directory while storing the current working directory for restoration at a later time
func NewWorkingDir ¶
NewWorkingDir creates a new temporary working directory