Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Case ¶
type Case struct { // Case is name for the given test scenario. Case, Path, Method string Body io.Reader Headers http.Header // Checkers is list of checkers to apply to the response of the request. // See functions like handler.CheckContains() on this package. Checkers []CheckerFunc // The setUp functions optionally allows configuring test dependencies, // like databases. SetUp TestAuxFunc // The tearDown functions optionally allows shutdown test dependencies, // like databases. TearDown TestAuxFunc }
Case represents a test case for an HTTP handler.
type CheckerFunc ¶
CheckerFunc represents a checker that will assert certain data in handler response.
func CheckContains ¶
func CheckContains(want string) CheckerFunc
CheckContains checks for a valid substring in the response body of an HTTP handler.
func CheckContainsJSON ¶
func CheckContainsJSON(expectedJSON string) CheckerFunc
CheckContainsJSON checks that the provided JSON string matches the one in the response body.
func CheckHasHeaders ¶
func CheckHasHeaders(want http.Header) CheckerFunc
CheckHasHeaders checks the wanted headers are present in the response.
This only checks that the specified headers are present with its respective values. This means that it could be more headers than the expected. In this case the test will pass.
func CheckHasStatus ¶
func CheckHasStatus(want int) CheckerFunc
CheckHasStatus checks for the specified HTTP status code in the handler response.
func CheckMatchesMD5 ¶
func CheckMatchesMD5(expectedMD5 string) CheckerFunc
CheckMatchesMD5 checks that the response body of an HTTP handler is equal to the expected MD5 sum.
type TestAuxFunc ¶
TestAuxFunc its the type for functions used to bring up/down services, as databases, before and after a handler test is executed.