handlertest

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockAsserter

type MockAsserter interface {
	AssertExpectations(t mock.TestingT) bool
}

MockAsserter is the interface that needs to be fulfilled by the mocks that are passed in.

type Params

type Params struct {
	Route             string
	Method            string
	Body              interface{}
	Headers           map[string]string
	PathParams        []PathParam
	Query             map[string]string
	Middleware        []echo.MiddlewareFunc
	SleepBeforeAssert time.Duration
}

Params contains all settings that should be used when calling the handler.

type PathParam

type PathParam struct {
	Name  string
	Value string
}

PathParam defines the name and value for a parameter in the URL.

type Suite

type Suite struct {
	DefaultMiddleware []echo.MiddlewareFunc
	DefaultHeaders    map[string]string
}

Suite holds the general properties to run handler tests.

func (*Suite) CallHandler

func (s *Suite) CallHandler(t *testing.T, handlerFunc echo.HandlerFunc, params *Params, mocks []MockAsserter) (*httptest.ResponseRecorder, error)

CallHandler calls the given handler with the provided settings. Afterwards it calls "AssertExpectations" of the provided mocks.

Jump to

Keyboard shortcuts

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