Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestContext ¶
NewTestContext() creates and returns a new test context by using the response and request pair from NewTestRequestPair()
func NewTestRequestPair ¶
func NewTestRequestPair() (http.ResponseWriter, *http.Request)
NewTestRequestPair() creates a new test request/response pair for testing against a Context or any roundtripping code. The request is a simple GET / request and the response is an instance of httptest.ResponseRecorder.
Types ¶
type ResponseExpectable ¶
ResponseExpectable saves current calling context when chaining exepctation methods. Do not use directly. Use one of the Http* method to obtain this and then use Expect method to setup test expectations.
func HttpGet ¶
func HttpGet(t *testing.T, url string) *ResponseExpectable
HttpGet() starts a new HTTP GET request and returns an object for setting up expectation for the result.
func HttpPost ¶
HttpPost() starts a new HTTP POST request with the given data payload and returns an object for setting up expectation for the result.
func (*ResponseExpectable) Expect ¶
func (r *ResponseExpectable) Expect(code int, body string)
Expect() reads the response body and tests if the response status code and body content matches the supplied values.
func (*ResponseExpectable) ExpectPattern ¶
func (r *ResponseExpectable) ExpectPattern(code int, pattern string)
ExpectPattern() is similar to Expect() but the response body is matched against the given regular expression pattern instead.
type TestFilter ¶
type TestFilter struct { z.Filter Called bool CallTime time.Time Finished bool FinishTime time.Time }
func NewTestFilter ¶
func NewTestFilter() *TestFilter
func (*TestFilter) Reset ¶
func (tf *TestFilter) Reset()