test_helpers

package
v0.0.0-...-a85dc47 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeResponseToType

func DecodeResponseToType(recorder *httptest.ResponseRecorder, target interface{}) error

DecodeResponseToType is a test helper function that decodes recorded response body to a specific struct type Note: this functions panics on error. For test usage only, not for production.

func MapFromJSON

func MapFromJSON(data []byte) map[string]interface{}

MapFromJSON is a test helper function that decodes recorded response body to a specific struct type Note: this functions panics on error. For test usage only, not for production.

Types

type AuthOptions

type AuthOptions struct {
	APIUser domain.IUser
	Token   string
}

type TestContextMiddleware

type TestContextMiddleware struct {
}

func NewTestContextMiddleware

func NewTestContextMiddleware() *TestContextMiddleware

func (*TestContextMiddleware) Handler

func (middleware *TestContextMiddleware) Handler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc, ctx domain.IContext)

type TestMiddleware

type TestMiddleware struct {
}

func NewTestMiddleware

func NewTestMiddleware() *TestMiddleware

func (*TestMiddleware) Handler

func (middleware *TestMiddleware) Handler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

type TestRequestBody

type TestRequestBody struct {
	Value string
}

type TestResource

type TestResource struct {
	Renderer domain.IRenderer
	Options  *TestResourceOptions
	// contains filtered or unexported fields
}

func NewTestResource

func NewTestResource(ctx domain.IContext, r domain.IRenderer, options *TestResourceOptions) *TestResource

TestResource implements IResource

func (*TestResource) Context

func (resource *TestResource) Context() domain.IContext

func (*TestResource) HandleAllACL

func (resource *TestResource) HandleAllACL(req *http.Request, user domain.IUser) (bool, string)

func (*TestResource) HandleGetRoute

func (resource *TestResource) HandleGetRoute(w http.ResponseWriter, req *http.Request)

func (*TestResource) HandlePostRoute

func (resource *TestResource) HandlePostRoute(w http.ResponseWriter, req *http.Request)

func (*TestResource) Render

func (resource *TestResource) Render(w http.ResponseWriter, req *http.Request, status int, v interface{})

func (*TestResource) Routes

func (resource *TestResource) Routes() *domain.Routes

type TestResourceOptions

type TestResourceOptions struct {
	NilRoutes bool
}

type TestResponseBody

type TestResponseBody struct {
	Result string
	Value  string
}

type TestServer

type TestServer struct {
	Options        *TestServerOptions
	Server         *server.Server
	Router         *server.Router
	TokenAuthority sessionsDomain.ITokenAuthority
	Database       domain.IDatabase
	Renderer       domain.IRenderer
}

func NewTestServer

func NewTestServer(options *TestServerOptions) *TestServer

func (*TestServer) AddMiddlewares

func (ts *TestServer) AddMiddlewares(middlewares ...interface{})

func (*TestServer) AddResources

func (ts *TestServer) AddResources(resources ...domain.IResource)

func (*TestServer) Request

func (ts *TestServer) Request(method string, urlStr string, body interface{}, targetResponse interface{}, authOptions *AuthOptions) *httptest.ResponseRecorder

func (*TestServer) Run

func (ts *TestServer) Run()

type TestServerOptions

type TestServerOptions struct {
	RequestAcceptHeader string
	PrivateSigningKey   []byte
	PublicSigningKey    []byte
	TokenAuthority      sessionsDomain.ITokenAuthority
	Database            domain.IDatabase
	Renderer            domain.IRenderer
	Resources           []domain.IResource
	Middlewares         []interface{}
}

Jump to

Keyboard shortcuts

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