testutils

package
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2017 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testutils provides utilities for writing gologin tests.

Index

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) http.Handler

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

func AssertSuccessNotCalled

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

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

func NewErrorServer

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

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

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.

Types

type RewriteTransport

type RewriteTransport struct {
	Transport http.RoundTripper
}

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

func (*RewriteTransport) RoundTrip

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL