httphelpers

package
v0.0.0-...-78f8226 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockHTTPRequest

func MockHTTPRequest(handler func(c *gin.Context), method string, callback func(MockRequest))

MockHTTPRequest sets up a gin server with only the handler action to test it

Types

type MockRequest

type MockRequest interface {
	MakeRequest(*RequestOptions) *httptest.ResponseRecorder
}

MockRequest is an interface for mocking requests

type RequestOptions

type RequestOptions struct {
	Params   map[string]string
	PostForm map[string]string
	Headers  map[string]string
}

RequestOptions hold test options to be set when making a request

func NewRequestOptions

func NewRequestOptions() (o *RequestOptions)

NewRequestOptions returns a new RequestOptions

func (*RequestOptions) AddHeaders

func (o *RequestOptions) AddHeaders(key string, value string)

AddHeaders adds a key, value to Headers

func (*RequestOptions) AddParams

func (o *RequestOptions) AddParams(key string, value string)

AddParams adds a key, value to Params

func (*RequestOptions) AddPostForm

func (o *RequestOptions) AddPostForm(key string, value string)

AddPostForm adds a key, value to PostForm

type TestRequest

type TestRequest struct {
	Method string
	Path   string
	Router *gin.Engine
}

TestRequest holds info for mocking a request

func (*TestRequest) MakeRequest

MakeRequest makes a http request and returns the ResponseRecorder

Jump to

Keyboard shortcuts

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