testttp

package module
v0.0.0-...-3a90299 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Req

type Req struct {
	// contains filtered or unexported fields
}

Req is a request builder.

func Delete

func Delete(addr string) *Req

Delete creates a DELETE request.

func Get

func Get(addr string) *Req

Get creates a GET request.

func HTTP

func HTTP(method, addr string, body io.Reader) *Req

HTTP runs creates a request for an http call.

func Patch

func Patch(addr string, body io.Reader) *Req

Patch creates a PATCH request.

func Post

func Post(addr string, body io.Reader) *Req

Post creates a POST request.

func Put

func Put(addr string, body io.Reader) *Req

Put creates a PUT request.

func (*Req) Do

func (r *Req) Do(handler http.Handler) *Resp

Do runs the request against the provided handler.

func (*Req) Headers

func (r *Req) Headers(k, v string, rest ...string) *Req

Headers allows the user to set headers on the http request.

type Resp

type Resp struct {
	Req *http.Request
	Rec *httptest.ResponseRecorder
}

Resp is a http recorder wrapper.

func (*Resp) Expect

func (r *Resp) Expect(fn func(*Resp)) *Resp

Expect allows the assertions against the raw Resp.

func (*Resp) ExpectBody

func (r *Resp) ExpectBody(fn func(*bytes.Buffer)) *Resp

ExpectBody provides an assertion against the recorder body.

func (*Resp) ExpectHeader

func (r *Resp) ExpectHeader(t *testing.T, k, v string) *Resp

ExpectHeader asserts that the header is in the recorder.

func (*Resp) ExpectStatus

func (r *Resp) ExpectStatus(t *testing.T, code int) *Resp

ExpectStatus compares the expected status code against the recorded status code.

Jump to

Keyboard shortcuts

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