Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestServer ¶
type TestServer struct { URL string // contains filtered or unexported fields }
TestServer wraps around httptest.Server to support expectations and timeout tests. Use ExpectAndRespond and ExpectAndHang methods to indicate expected requests in the order they should arrive.
Currently, parallel requests are not supported.
func NewTestServer ¶
func NewTestServer(t *testing.T) *TestServer
NewTestServer creates a new TestServer associate with given testing.T instance
func (*TestServer) CloseAndAssertExpectations ¶
func (ts *TestServer) CloseAndAssertExpectations()
CloseAndAssertExpectations will stop any hanging requests and shutdown the test server. Any remaining expectations will flag a test error.
func (*TestServer) ExpectAndHang ¶
func (ts *TestServer) ExpectAndHang(method string, url string) *TestServer
ExpectAndHang specifies the next request expected, the server hangs and the request will not be responded to. This is useful to test client timeouts. To stop the hanging server, call CloseAndAssertExpectations.
func (*TestServer) ExpectAndRespond ¶
func (ts *TestServer) ExpectAndRespond(method string, url string, responseCode int, responseBytes string) *TestServer
ExpectAndRespond specifies the next request to be expected (using request method and url) and specifies what response needs to be provided.