Documentation ¶
Index ¶
- func AssertBackendErrorCode(testName string, bslice *[]byte, errCode int, t *testing.T)
- func AssertRoute(method, route string, code int, t *testing.T) (*[]byte, bool)
- func AssertRouteMultipleArgs(method string, route string, body *bytes.Buffer, code int, signedToken *string, ...) (*[]byte, bool)
- func AssertRouteWithBody(method, route string, body *bytes.Buffer, code int, t *testing.T) (*[]byte, bool)
- func CreateTmpFolderWithContents(folderName string, files []FileDesc) (string, error)
- func GetIndentedTraceToTest() string
- func InvalidRouteTestHelper(t *testing.T)
- func OptionsTestHelper(uris []string, routenames []string, t *testing.T)
- func SendMultipartMethod(testName string, t *testing.T, method, uri string, jwt *string, ...) (respCode int, bslice *[]byte, ok bool)
- func SendMultipartPOST(testName string, t *testing.T, uri string, jwt *string, ...) (respCode int, bslice *[]byte, ok bool)
- func SetupTest(_router http.Handler)
- type AssertResponse
- type FileDesc
- type RequestArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertBackendErrorCode ¶
AssertBackendErrorCode is a function that tries to unmarshal a backend's ErrMsg and compares to given error code
func AssertRoute ¶
AssertRoute is a helper function that checks for a valid route \param[in] method One of "GET", "PATCH", "PUT", "POST", "DELETE", "OPTIONS" \param[in] route The URL string \param[in] code The expected result HTTP code \param[in] t Testing pointer \return[out] *[]byte A pointer to a bytes slice containing the response body. \return[out] bool A flag indicating if the operation was ok.
func AssertRouteMultipleArgs ¶
func AssertRouteMultipleArgs(method string, route string, body *bytes.Buffer, code int, signedToken *string, contentType string, t *testing.T) (*[]byte, bool)
AssertRouteMultipleArgs is a helper function that checks for a valid route. \param[in] method One of "GET", "PATCH", "PUT", "POST", "DELETE" \param[in] route The URL string \param[in] body The body to send in the request, or nil \param[in] code The expected response HTTP code \param[in] signedToken JWT token as base64 string, or nil. \param[in] contentType The expected response content type \param[in] t Test pointer \return[out] *[]byte A pointer to a bytes slice containing the response body. \return[out] bool A flag indicating if the operation was ok.
func AssertRouteWithBody ¶
func AssertRouteWithBody(method, route string, body *bytes.Buffer, code int, t *testing.T) (*[]byte, bool)
AssertRouteWithBody is a helper function that checks for a valid route \return[out] *[]byte A pointer to a bytes slice containing the response body. \return[out] bool A flag indicating if the operation was ok.
func CreateTmpFolderWithContents ¶
CreateTmpFolderWithContents creates a tmp folder with the given files and returns the path to the created folder. See type fileDesc above.
func GetIndentedTraceToTest ¶
func GetIndentedTraceToTest() string
GetIndentedTraceToTest returns a formatted and indented string containing the file and line number of each stack frame leading from the current test to the assert call that failed.
func InvalidRouteTestHelper ¶
InvalidRouteTestHelper is a helper test function that just invokes an invalid route
func OptionsTestHelper ¶
OptionsTestHelper is a helper function to test the autogenerated OPTIONS urls, given a set of Routes' URIs. This function should be called from each specific project that defines routes.
func SendMultipartMethod ¶
func SendMultipartMethod(testName string, t *testing.T, method, uri string, jwt *string, params map[string]string, files []FileDesc) (respCode int, bslice *[]byte, ok bool)
SendMultipartMethod executes a multipart POST/PUT/PATCH request with the given form fields and multipart files, and returns the received http status code, the response body, and a success flag.
func SendMultipartPOST ¶
func SendMultipartPOST(testName string, t *testing.T, uri string, jwt *string, params map[string]string, files []FileDesc) (respCode int, bslice *[]byte, ok bool)
SendMultipartPOST executes a multipart POST request with the given form fields and multipart files, and returns the received http status code, the response body, and a success flag.
Types ¶
type AssertResponse ¶
type AssertResponse struct { Ok bool RespRecorder *httptest.ResponseRecorder BodyAsBytes *[]byte }
AssertResponse - response of AssertRouteMultipleArgsStruct func.
func AssertRouteMultipleArgsStruct ¶
func AssertRouteMultipleArgsStruct(args RequestArgs, expCode int, contentType string, t *testing.T) *AssertResponse
AssertRouteMultipleArgsStruct is a convenient helper function that accepts input arguments as a struct, allowing us to keep extending the number of args without changing the func signature and the corresponding invocation code everywhere. \param[in] args RequestArgs struct \param[in] expCode The expected response HTTP code \param[in] contentType The expected response content type \param[in] t Test pointer \return[out] *AssertResponse A pointer to a AssertResponse struct with the response.
type FileDesc ¶
FileDesc describes a file to be created. It is used by func CreateTmpFolderWithContents and sendMultipartPOST. Fields: path: is the file path to be sent in the multipart form. contents: is the string contents to write in the file. Note: if contents value is ":dir" then a Directory will be created instead of a File. This is only valid when used with CreateTmpFolderWithContents func.