Documentation ¶
Index ¶
- func MustGET(ctx context.Context, t *testing.T, addr string) *http.Response
- func MustPost(ctx context.Context, t *testing.T, addr, contentType string, body io.Reader) *http.Response
- func MustReadFullyJSON[T ~*E, E any](t *testing.T, resp *http.Response, target T)
- func MustReadFullyString(t *testing.T, resp *http.Response) string
- func ReadFully(resp *http.Response) ([]byte, error)
- func ReadFullyJSON[T ~*E, E any](resp *http.Response, target T) (err error)
- func ReadFullyString(resp *http.Response) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustGET ¶
MustGET performs an HTTP GET request to the specified address and returns the response. It is used in tests to make sure the request is successful, otherwise it will fail the test.
func MustReadFullyJSON ¶
MustReadFullyJSON reads the response body from an HTTP response and populates the target variable with the JSON data. It is used in tests to ensure that the response body is successfully read and parsed as JSON, otherwise it will fail the test. The resp parameter is the HTTP response that contains the JSON data to be read. The target parameter is the variable where the parsed JSON data will be stored. The function returns the target variable with the JSON data. If there is an error reading or parsing the JSON data, the function will fail the test and return an error message.
func MustReadFullyString ¶
MustReadFullyString reads all the data from the specified `io.ReadCloser` and returns it as a string. If there is an error while reading or converting to string, it returns an empty string and the error.
func ReadFully ¶
ReadFully reads all the data from the specified `io.ReadCloser` and returns it as a byte slice. If there is an error while reading, it returns `nil` and the error.
func ReadFullyJSON ¶
ReadFullyJSON reads the response body from an HTTP response and populates the target variable with the JSON data. The resp parameter is the HTTP response that contains the JSON data to be read. The target parameter is the variable where the parsed JSON data will be stored. The function returns an error if there is a problem reading or parsing the JSON data.
Types ¶
This section is empty.