Documentation
¶
Index ¶
- Constants
- func Assert(tb testing.TB, callerSkip int, condition bool, msg string, v ...interface{})
- func CheckHTTPStatus(t *testing.T, callDepth int, rr *httptest.ResponseRecorder, expectedStatus int)
- func Equals(tb testing.TB, callerSkip int, exp, act interface{})
- func Ok(tb testing.TB, callerSkip int, err error)
- type APITestInfo
- type APITester
Constants ¶
View Source
const ( // CallFromTestFile to use when Assert() is used in a test file CallFromTestFile = 2 // CallFromHelperMethod to user when Asset() is used from a helper method CallFromHelperMethod = 3 )
Variables ¶
This section is empty.
Functions ¶
func CheckHTTPStatus ¶
func CheckHTTPStatus(t *testing.T, callDepth int, rr *httptest.ResponseRecorder, expectedStatus int)
CheckHTTPStatus makes a test fails if the response recorder status code is not the expected code
Types ¶
type APITestInfo ¶
type APITestInfo struct {
Path string
Method string
Version string // default to core.APIv1
Payload interface{}
AuthToken string
Headers map[string]string
ExpectedHTTPStatus int
}
APITestInfo gathers info for a single test run
type APITester ¶
type APITester struct {
// contains filtered or unexported fields
}
APITester saves a router and run tests against the saved router
func NewAPITester ¶
NewAPITester build an APITester from a core.API reference. router is built in microservice mode
func (*APITester) ServeHTTP ¶
func (at *APITester) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*APITester) ServeReq ¶
func (at *APITester) ServeReq(req *http.Request) *httptest.ResponseRecorder
ServeReq serves a given request and returns the ResponseRecorder for the request
func (*APITester) TestPath ¶
func (at *APITester) TestPath(t *testing.T, apiTest APITestInfo) *httptest.ResponseRecorder
TestPath tests a single API call and returns the generated ResponseRecorder
Click to show internal directories.
Click to hide internal directories.