httptests

package
v0.0.0-...-6907ca9 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2018 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRouter *mux.Router

DefaultRouter represents the router to be used if none are specified

Functions

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(s *auth.Session) *RequestAuth

NewRequestAuth creates a new request auth

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() (mime string, body io.Reader, err error)

Body returns the full Body of the request

func (*RequestInfo) BodyJSON

func (ri *RequestInfo) BodyJSON() (mime string, body io.Reader, err error)

BodyJSON returns the body of the request encoded in JSON FIXME(melvin): because the data are from a map of string, all the

JSON data will also be string. There's no way to use the output
to recreate a new JSON object containing non string value

func (*RequestInfo) BodyMultipart

func (ri *RequestInfo) BodyMultipart() (mime string, body io.Reader, err error)

BodyMultipart returns the body of the request as multipart data

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