httptests

package
v0.0.0-...-a114734 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is2XX

func Is2XX(code int) bool

Is2XX returns a true if the HTTP code is a 2XX, false otherwise

func NewRequest

func NewRequest(t *testing.T, info *RequestInfo) *httptest.ResponseRecorder

NewRequest simulates a new http request executed against the api

Types

type RequestAuth

type RequestAuth struct {
	SessionID string
	UserID    string
}

RequestAuth represents the auth data for a request

func NewRequestAuth

func NewRequestAuth(sessionID string, userID string) *RequestAuth

NewRequestAuth creates a new

func (*RequestAuth) ToBasicAuth

func (ra *RequestAuth) ToBasicAuth() string

ToBasicAuth returns the data using the basic auth format

type RequestInfo

type RequestInfo struct {
	Endpoint *router.Endpoint

	Params interface{}  // Optional
	Auth   *RequestAuth // Optional
	// Router is used to parse Mux Variables. Default on the api router
	Router *mux.Router
	// contains filtered or unexported fields
}

RequestInfo represents the params accepted by NewRequest

func (*RequestInfo) Body

func (ri *RequestInfo) Body() (*bytes.Buffer, error)

Body returns the full Body of the request

func (*RequestInfo) ParseParams

func (ri *RequestInfo) ParseParams()

ParseParams parses the params and copy them in the right list: urlParams, bodyParams, and queryParams

func (*RequestInfo) PopulateQuery

func (ri *RequestInfo) PopulateQuery(qs *url.Values)

PopulateQuery populate the query string of a request

func (*RequestInfo) URL

func (ri *RequestInfo) URL() string

URL returns the full URL

Jump to

Keyboard shortcuts

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