mockhttp

package module
v0.0.0-...-c323b80 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2014 License: MIT Imports: 5 Imported by: 0

README

mockhttp -- Go package for unit testing HTTP serving

Unit testing HTTP services written in Go means you need to call their ServeHTTP receiver. For this, you need something that fulfills the http.ResponseWriter interface, and you need to populate a http.Request struct with suitable-looking data. mockhttp.go helps you do these tasks, without excessive copy-pasting.

See mockhttp_test.go for an example of usage.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(t *testing.T, w *httptest.ResponseRecorder, wantStatus int, wantHeaders http.Header, wantBody string) (ok bool)

CheckResponse checks that the http response matches expectations, and calls t.Error if not.

func NewRequest

func NewRequest(t testing.TB, method, url string, body io.Reader) *http.Request

NewRequest is like http.NewRequest, but calls t.Fatal on error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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