gologin: github.com/dghubble/gologin/testutils Index | Files

package testutils

import "github.com/dghubble/gologin/testutils"

Package testutils provides utilities for writing gologin tests.

Index

Package Files

asserts.go server.go

func AssertBodyString Uses

func AssertBodyString(t *testing.T, rc io.ReadCloser, expected string)

AssertBodyString asserts that a Request Body matches the expected string.

func AssertFailureNotCalled Uses

func AssertFailureNotCalled(t *testing.T) http.Handler

AssertFailureNotCalled is a failure http.Handler that fails if called.

func AssertSuccessNotCalled Uses

func AssertSuccessNotCalled(t *testing.T) http.Handler

AssertSuccessNotCalled is a success http.Handler that fails if called.

func NewErrorServer Uses

func NewErrorServer(message string, code int) (*http.Client, *httptest.Server)

NewErrorServer returns a new httptest.Server, which responds with the given error message and code, and a client which proxies requests to the server using a custom transport. The caller must close the server.

func NewTestServerFunc Uses

func NewTestServerFunc(handler func(w http.ResponseWriter, r *http.Request)) *httptest.Server

NewTestServerFunc is an adapter to allow the use of ordinary functions as httptest.Server's for testing. Caller must close the server.

func TestServer Uses

func TestServer() (*http.Client, *http.ServeMux, *httptest.Server)

TestServer returns a new httptest.Server, its ServeMux for adding handlers, and a client which proxies requests to the server using a custom transport. The caller must close the server.

type RewriteTransport Uses

type RewriteTransport struct {
    Transport http.RoundTripper
}

RewriteTransport rewrites https requests to http to avoid TLS cert issues during testing.

func (*RewriteTransport) RoundTrip Uses

func (t *RewriteTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip rewrites the request scheme to http and calls through to the composed RoundTripper or if it is nil, to the http.DefaultTransport.

Package testutils imports 7 packages (graph). Updated 2017-01-21. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).