autopilot

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 6 Imported by: 0

README

autopilot

A golang testing utils library

Go Reference

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Mux    *http.ServeMux
	Server *httptest.Server
)

Functions

func Assert

func Assert(tb testing.TB, condition bool, msg string, v ...interface{})

Assert fails the test if the condition is false.

func Equals

func Equals(tb testing.TB, exp, act interface{})

Equals fails the test if exp is not equal to act.

func Fixture

func Fixture(path string) string

Load testdata/fixtures/<path> and return as string

func NewHttpClient

func NewHttpClient(fn RoundTripFunc) *http.Client

Returns a Mock'd HttpClient

func Ok

func Ok(tb testing.TB, err error)

Ok fails the test if an err is not nil.

func RegisterEndpoint added in v0.1.3

func RegisterEndpoint(endpoint string, responseWriter ResponseWriter, requestValidation RequestValidation) string

func Setup

func Setup() func()

Setup an HttpTestServer and ServerMux (for path routing) and return the teardown function

Types

type RequestValidation added in v0.1.5

type RequestValidation func(*http.Request)

func SkipRequestValidation added in v0.1.5

func SkipRequestValidation() RequestValidation

type ResponseWriter added in v0.1.5

type ResponseWriter func(http.ResponseWriter)

func EmptyResponse added in v0.1.5

func EmptyResponse() ResponseWriter

func FixtureResponse added in v0.1.5

func FixtureResponse(fixture string) ResponseWriter

type RoundTripFunc

type RoundTripFunc func(req *http.Request) *http.Response

func (RoundTripFunc) RoundTrip

func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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