restaudit

package
v2.8.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2016 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

The Tideland Go REST Server Library restaudit package is a little helper package for the unit testing of the rest package and the resource handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyValues

type KeyValues map[string]string

KeyValues handles keys and values for request headers and cookies.

type Request

type Request struct {
	Method           string
	Path             string
	Header           KeyValues
	Cookies          KeyValues
	Body             []byte
	RequestProcessor func(req *http.Request) *http.Request
}

Request wraps all infos for a test request.

type Response

type Response struct {
	Status  int
	Header  KeyValues
	Cookies KeyValues
	Body    []byte
}

Response wraps all infos of a test response.

type TestServer

type TestServer interface {
	// Close shuts down the server and blocks until all outstanding
	// requests have completed.
	Close()

	// DoRequest performs a request against the test server.
	DoRequest(req *Request) *Response

	// DoUpload is a special request for uploading a file.
	DoUpload(path, fieldname, filename, data string) *Response
}

func StartServer

func StartServer(handler http.Handler, assert audit.Assertion) TestServer

StartServer starts a test server using the passed handler

Jump to

Keyboard shortcuts

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