Back to godoc.org

Package handlertest

v2.4.1
Latest Go to latest

The latest major version is v3.

Published: Mar 10, 2020 | License: MIT | Module: github.com/fastbill/go-service-toolkit/v2

Index

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.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier