endpoints_testing

package
v0.0.0-...-aa69435 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DummyGinBindingHandler

func DummyGinBindingHandler[I any]() http.HandlerFunc

func NewTestGinRouter

func NewTestGinRouter() endpoints.Router[gin.HandlerFunc]

func NewTestHttpRouter

func NewTestHttpRouter() endpoints.Router[http.HandlerFunc]

func RunScenarios

func RunScenarios[T any, R any](t *testing.T, fn func(context.Context, T) (R, error), scenarios []TestScenario[T, R])

Types

type BindingTestScaffold

type BindingTestScaffold struct {
	ModelScenarios []bindingScenario
	// contains filtered or unexported fields
}

func EnableModelBindingTests

func EnableModelBindingTests() *BindingTestScaffold

func (*BindingTestScaffold) ExecuteModelTestScenarios

func (binding *BindingTestScaffold) ExecuteModelTestScenarios(t *testing.T, assertions ...func(*http.Response, error))

func (*BindingTestScaffold) OnBind

func (binding *BindingTestScaffold) OnBind(input interface{}, handler endpoints.GinHandler)

type TestGinRouter

type TestGinRouter struct {
	// contains filtered or unexported fields
}

func (TestGinRouter) Handler

func (tr TestGinRouter) Handler() http.Handler

func (TestGinRouter) Register

func (tr TestGinRouter) Register(path, method string, handler gin.HandlerFunc, middleware ...gin.HandlerFunc)

func (TestGinRouter) ServeHTTP

func (tr TestGinRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)

type TestHttpRouter

type TestHttpRouter struct {
	// contains filtered or unexported fields
}

func (TestHttpRouter) Handler

func (tr TestHttpRouter) Handler() http.Handler

func (TestHttpRouter) Register

func (tr TestHttpRouter) Register(path, method string, handler http.HandlerFunc, middleware ...http.HandlerFunc)

func (TestHttpRouter) ServeHTTP

func (tr TestHttpRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)

type TestScenario

type TestScenario[T any, R any] struct {
	Name       string
	Given      T
	Expected   R
	Err        error
	Assertions func(t *testing.T, expected, actual R)
}

Jump to

Keyboard shortcuts

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