Documentation ¶
Overview ¶
Package testutils provides utilities for writing gologin tests.
Index ¶
- func AssertBodyString(t *testing.T, rc io.ReadCloser, expected string)
- func AssertFailureNotCalled(t *testing.T) ctxh.ContextHandler
- func AssertSuccessNotCalled(t *testing.T) ctxh.ContextHandler
- func NewErrorServer(t *testing.T, message string, code int) *httptest.Server
- func NewTestServerFunc(handler func(w http.ResponseWriter, r *http.Request)) *httptest.Server
- func TestServer() (*http.Client, *http.ServeMux, *httptest.Server)
- func UnauthorizedTestServer() (*http.Client, *httptest.Server)
- type RewriteTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertBodyString ¶
func AssertBodyString(t *testing.T, rc io.ReadCloser, expected string)
AssertBodyString asserts that a Request Body matches the expected string.
func AssertFailureNotCalled ¶
func AssertFailureNotCalled(t *testing.T) ctxh.ContextHandler
AssertFailureNotCalled is a failure ContextHandler that fails if called.
func AssertSuccessNotCalled ¶
func AssertSuccessNotCalled(t *testing.T) ctxh.ContextHandler
AssertSuccessNotCalled is a success ContextHandler that fails if called.
func NewErrorServer ¶
NewErrorServer returns a new httptest.Server endpoint which responds with the given error message and code. Caller must close the server.
func NewTestServerFunc ¶
NewTestServerFunc is an adapter to allow the use of ordinary functions as httptest.Server's for testing. Caller must close the server.
func TestServer ¶
TestServer returns an http Client, ServeMux, and Server. The client proxies requests to the server and handlers can be registered on the mux to handle requests. The caller must close the test server.
Types ¶
type RewriteTransport ¶
type RewriteTransport struct {
Transport http.RoundTripper
}
RewriteTransport rewrites https requests to http to avoid TLS cert issues during testing.