Documentation ¶
Overview ¶
Package testing is a framework package to be used inside services unit tests providing an API to build specific services unit tests.
Index ¶
- Constants
- func MockAny() gomock.Matcher
- func MockController(t *testing.T) *gomock.Controller
- type Options
- type RequestOptions
- type Response
- type Testing
- func (t *Testing) Assert() *assert.Assertions
- func (t *Testing) Delete(opts *RequestOptions) (*Response, error)
- func (t *Testing) Get(opts *RequestOptions) (*Response, error)
- func (t *Testing) HttpHandler() fasthttp.RequestHandler
- func (t *Testing) MockAny() gomock.Matcher
- func (t *Testing) MockController() *gomock.Controller
- func (t *Testing) Options() *Options
- func (t *Testing) Post(opts *RequestOptions) (*Response, error)
- func (t *Testing) Put(opts *RequestOptions) (*Response, error)
- func (t *Testing) SkipCICD()
- func (t *Testing) T() *testing.T
Constants ¶
const ( JSONContentType = "application/json" FormUrlencodedContentType = "application/x-www-form-urlencoded" FormDataContentType = "multipart/form-data" )
Variables ¶
This section is empty.
Functions ¶
func MockAny ¶
MockAny gives access to a gomock.Matcher object which can replace any kind of argument. This API can be called without a Testing object.
func MockController ¶
func MockController(t *testing.T) *gomock.Controller
MockController gives access to a gomock.Controller object that enables creating a service mock to be used inside tests. This API can be called without a Testing object.
Types ¶
type Options ¶
type Options struct { // Handler is the service main HTTP handler to be used inside a test. Handler fasthttp.RequestHandler // MockedFeatures is an array of features that will be mocked during the // test. MockedFeatures []interface{} // FeatureOptions is the mechanism that a test can pass specific features // options to be used by it. FeatureOptions map[string]interface{} }
Options gathers all available options that can be swapped inside a unit test. It is important that the Setup/Teardown API is used correctly to avoid receiving unexpected behavior.
type RequestOptions ¶
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) StatusCode ¶
type Testing ¶
type Testing struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new Testing object, to help building service unit tests. It can be used inside a Test function or test subset providing access to assertions and APIs to build specific required types when calling services handlers.
func (*Testing) Assert ¶
func (t *Testing) Assert() *assert.Assertions
Assert gives access to an assert object, providing an API to compare values between variables or objects.
func (*Testing) Delete ¶
func (t *Testing) Delete(opts *RequestOptions) (*Response, error)
Delete makes a DELETE request to a service's endpoint.
func (*Testing) Get ¶
func (t *Testing) Get(opts *RequestOptions) (*Response, error)
Get makes a GET request to a service's endpoint.
func (*Testing) HttpHandler ¶
func (t *Testing) HttpHandler() fasthttp.RequestHandler
HttpHandler gives access to the service HTTP request handler.
func (*Testing) MockController ¶
func (t *Testing) MockController() *gomock.Controller
MockController gives access to a gomock.Controller object that enables creating a service mock to be used inside tests.
func (*Testing) Post ¶
func (t *Testing) Post(opts *RequestOptions) (*Response, error)
Post makes a POST request to a service's endpoint.
func (*Testing) Put ¶
func (t *Testing) Put(opts *RequestOptions) (*Response, error)
Put makes a PUT request to a service's endpoint.