Documentation ¶
Overview ¶
Package mock contains testing utilities and mocks shared between packages.
Index ¶
- func GetHeaderParam(r *http.Request, key string) string
- func GetQueryParam(r *http.Request, key string) string
- func GetQueryParamForBool(r *http.Request, key string) (bool, error)
- func GetQueryParamForInt(r *http.Request, key string) (int64, error)
- func GetQueryParamForTime(r *http.Request, key string) (convert.JSONTime, error)
- func GetURLParam(r *http.Request, key string) string
- func GetURLParamForInt(r *http.Request, key string) int64
- func OnRestResultHTTPResult(ctx context.Context, result *HTTPResult, err error)
- func ReadCloser() io.ReadCloser
- func ResponseWriter() http.ResponseWriter
- func SendHTTPResponse(w http.ResponseWriter, httpStatus int, responses ...interface{})
- func SetHeaders(w http.ResponseWriter, headerMap http.Header)
- func SetRestResult(ctx context.Context, result common.RestResult)
- type HTTPRequest
- type HTTPResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetQueryParamForBool ¶ added in v0.36.0
func GetQueryParamForInt ¶ added in v0.36.0
func GetQueryParamForTime ¶ added in v0.36.0
func OnRestResultHTTPResult ¶ added in v0.69.0
func OnRestResultHTTPResult(ctx context.Context, result *HTTPResult, err error)
OnRestResultHTTPResult is called from generated code when an HTTP result is retrieved. The current implementation of restlib.DoHTTPRequest returns an *HTTPResult as an error when a non- successful status code is received. The implementation of this method relies on this behaviour. to set the rest result in the event of a failed request.
func ReadCloser ¶ added in v0.26.0
func ReadCloser() io.ReadCloser
ReadCloser returns a mock io.ReadCloser that can be set to return an err when Read is called on it and do nothing when Close is called on it.
func ResponseWriter ¶ added in v0.26.0
func ResponseWriter() http.ResponseWriter
ResponseWriter returns a mock ResponseWriter implementing http.ResponseWriter.
func SendHTTPResponse ¶
func SendHTTPResponse(w http.ResponseWriter, httpStatus int, responses ...interface{})
SendHTTPResponse sends the http response to the client.
func SetHeaders ¶
func SetHeaders(w http.ResponseWriter, headerMap http.Header)
SetHeaders sets the headers in response.
func SetRestResult ¶ added in v0.74.0
func SetRestResult(ctx context.Context, result common.RestResult)
SetRestResult the contents of the common.RestResult stored in the context. The RestResult is stored in the context through the common.ProvisionRestResult method. This method is exported so that unit tests can set the rest result with appropriate values as required.
Types ¶
type HTTPRequest ¶ added in v0.85.0
type HTTPResult ¶
HTTPResult is the result return by the library.
func DoHTTPRequest ¶
func DoHTTPRequest(ctx context.Context, config *HTTPRequest) (*HTTPResult, error)
DoHTTPRequest returns HTTPResult.
func (*HTTPResult) Error ¶
func (r *HTTPResult) Error() string