routertest

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RouterTest

type RouterTest struct {
	*appctxtest.AppCtxTest
	TemplatesFS filesystem.FS
	Router      http.Handler
	APIClient   *TestAPIClient
}

RouterTest allows for testing the server's Router

func SetupTest

func SetupTest(t *testing.T) *RouterTest

SetupTest returns a new RouterTest

func (*RouterTest) PostForm

func (routerTest *RouterTest) PostForm(path string, form *url.Values) *httptest.ResponseRecorder

PostForm will post a form

func (*RouterTest) ServeHTTP

func (routerTest *RouterTest) ServeHTTP(request *http.Request) *httptest.ResponseRecorder

ServeHTTP serves an http request

type TestAPIClient

type TestAPIClient struct {
	*apiclient.APIClient
	// contains filtered or unexported fields
}

TestAPIClient embeds an API client and allows to retrieve its last request

func (*TestAPIClient) LastRecorder

func (c *TestAPIClient) LastRecorder() *httptest.ResponseRecorder

LastRecorder returns the last response recorder used by the HTTP client

func (*TestAPIClient) LastResponse

func (c *TestAPIClient) LastResponse() *http.Response

LastResponse returns the last response returned to the APIClient

Jump to

Keyboard shortcuts

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