test

package
v0.0.0-...-6c46dfd Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoTestRequest

func DoTestRequest(t *testing.T, method string, slug string, body string, header http.Header) (*http.Response, error)

DoTestRequest will execute a request againt the service specified in the SERVICE_HOST env var

func InvokeAndCheck

func InvokeAndCheck(t *testing.T, handler martini.Handler, i *Injector, expectedStatus int, expectedBody []byte)

InvokeAndCheck will invoke a handler with the provided injector and check its return values

func Ping

func Ping() martini.Handler

Ping returns a ping handler

func VerifyResponse

func VerifyResponse(t *testing.T, res *http.Response, err error, expectedStatus int) []byte

VerifyResponse will make sure that the response matches the expected status

func VerifyResponseBody

func VerifyResponseBody(t *testing.T, res *http.Response, err error, expectedStatus int, expectedBody []byte)

VerifyResponseBody will make sure the response matches the expected status and body

Types

type Injector

type Injector struct {
	inject.Injector
	// contains filtered or unexported fields
}

Injector is a testing helper that can invoke martini handlers

func NewInjector

func NewInjector(method string, body string) *Injector

NewInjector creates a TestInjector

func (*Injector) SetHeaders

func (i *Injector) SetHeaders(h http.Header)

SetHeaders sets the headers on the internal request

func (*Injector) SetParams

func (i *Injector) SetParams(p martini.Params)

SetParams sets up DI for martinit params

func (*Injector) SetQueryParams

func (i *Injector) SetQueryParams(params map[string]string)

SetQueryParams will set URL Query parameters on the request

Jump to

Keyboard shortcuts

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