Documentation
¶
Index ¶
- Constants
- type DBAny
- type DBAnyJSONMessage
- type DBAnyString
- type DBSuite
- type HandlerSuite
- func (t *HandlerSuite) ContentType() string
- func (t *HandlerSuite) NewRequest(method, url string, body io.Reader)
- func (t *HandlerSuite) RequestAndServe(method, url, engineURL string, body interface{}, ...)
- func (t *HandlerSuite) Reset()
- func (t *HandlerSuite) RespondData() (RespondJSON, string)
- func (t *HandlerSuite) RunT(want interface{}, status int, message string)
- func (t *HandlerSuite) ServeHTTP()
- func (t *HandlerSuite) Status() int
- type RespondJSON
Constants ¶
const (
// The header to be expected to be received from the API.
JSONHeader = "application/json; charset=utf-8"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBSuite ¶
type DBSuite struct { suite.Suite DB *sqlx.DB Driver *mocks.Driver Mock sqlMock.Sqlmock Logger *bytes.Buffer // contains filtered or unexported fields }
HandlerSuite represents the suite of testing methods for controllers.
func (*DBSuite) Reset ¶
func (t *DBSuite) Reset()
Reset
Sets up a new mock, driver and database upon test completion.
func (*DBSuite) RunExpectationsT ¶ added in v0.0.3
func (t *DBSuite) RunExpectationsT(want, actual interface{})
RunExpectationsT runs the DB test and asserts the expectations were met.
type HandlerSuite ¶
type HandlerSuite struct { suite.Suite Recorder *httptest.ResponseRecorder Context *gin.Context Engine *gin.Engine }
HandlerSuite represents the suite of testing methods for controllers.
func NewHandlerSuite ¶
func NewHandlerSuite() HandlerSuite
NewHandlerSuite
New recorder for testing controllers, initialises gin & sets gin mode.
func (*HandlerSuite) ContentType ¶
func (t *HandlerSuite) ContentType() string
ContentType
Returns the recorder's content type.
func (*HandlerSuite) NewRequest ¶
func (t *HandlerSuite) NewRequest(method, url string, body io.Reader)
NewRequest
Creates a new http.Request and assigns the gin testing the request.
func (*HandlerSuite) RequestAndServe ¶
func (t *HandlerSuite) RequestAndServe(method, url, engineURL string, body interface{}, handler func(ctx *gin.Context))
RequestAndServe
Makes a new http.Request and assigns the gin testing the request, serves HTTP.
func (*HandlerSuite) Reset ¶
func (t *HandlerSuite) Reset()
Reset
Sets up a new recorder, engine and context upon test completion.
func (*HandlerSuite) RespondData ¶
func (t *HandlerSuite) RespondData() (RespondJSON, string)
RespondData
Returns the RespondJSON and the data decoded in string form.
func (*HandlerSuite) RunT ¶
func (t *HandlerSuite) RunT(want interface{}, status int, message string)
RunT
Run the API test.
func (*HandlerSuite) ServeHTTP ¶
func (t *HandlerSuite) ServeHTTP()
func (*HandlerSuite) Status ¶
func (t *HandlerSuite) Status() int
Status
Returns the recorder's status code.
type RespondJSON ¶
type RespondJSON struct { Status int `json:"status"` Error bool `json:"error"` Message string `json:"message"` Meta struct { RequestTime string `json:"request_time"` ResponseTime string `json:"response_time"` LatencyTime string `json:"latency_time"` Pagination interface{} `json:"pagination,omitempty"` } `json:"meta"` Data interface{} `json:"data"` }
RespondJSON is an abstraction of the api.RespondJSON