Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestCase ¶
type TestCase struct { Name string RequestBody string HttpVerb string Uri string WantStatusCode int WantResponseBody string SkipFlag bool // *testing.T context.Context http.Handler }
func (TestCase) RunCase ¶
func (tc TestCase) RunCase()
Method RunCase does same thing as RunCheckStatusCode. The major difference is that, instead of returning the (got) response body, RunCase compares the want response body with the got, and pass/fail the test case accordingly.
The order of elements in the json (between got and want) is not strict, however, all the fields in the want should exist in got (including the empty fields), and vice versa. otherwise the test fails.
func (TestCase) RunCheckStatusCode ¶
Method RunCheckStatusCode, for the given test case record, invokes the call to the API on the given test server, compares want response status code to the got. This method doesn't check the response body, but will return the got response body to the caller. Caller is responsible to test for the response body. This limitation is helpful in situations where the response body cannot be directly tested, for example, if the response body contains undeterministic fields like created date, modified date. If that is not the case, use the RunCase() method instead.