testserver

package
v0.0.0-...-d0bbcc7 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailHandler

type FailHandler func(string, ...int)

FailHandler is a function that will be called when something unexpected happens in the test server.

type Server

type Server interface {
	// Close shuts down the server and blocks until all outstanding
	// requests on this server have completed.
	Close()
	// Get retrieves the transaction registered for a given
	// method/path combination. May return nil
	Get(method, path string) *Transaction
	// Set registers a transaction for a given
	// method/path combination. May be set to nil,
	// however, a request to that method/path will cause the server
	// to call the Fail handler
	Set(method, path string, transaction *Transaction)
	// URL returns the url the test server is running at
	URL() string
}

Server has transactions and can be closed

func New

func New(onFail FailHandler) Server

New constructs a new Server

type Transaction

type Transaction struct {
	Request         *http.Request
	ResponseBodyStr string
	ResponseBody    []byte
	ResponseStatus  int
}

Transaction defines the response of an an http request, as well as store the request made

Jump to

Keyboard shortcuts

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