apitest

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockGinContext

func MockGinContext() (ctx *gin.Context)

MockGinContext :

func MockHTTPClient

func MockHTTPClient() (c *http.Client)

MockHTTPClient :

func MockHTTPServer

func MockHTTPServer(container service.Container) (server *http.Server)

MockHTTPServer :

func MockHTTPServerNoCSRF added in v0.2.0

func MockHTTPServerNoCSRF(container service.Container) (server *http.Server)

MockHTTPServerNoCSRF :

func MockHTTPServerWithWebsocketSupport

func MockHTTPServerWithWebsocketSupport(container service.Container) (server *websocket.Server, srv *netHttp.Server, port string)

MockHTTPServerWithWebsocketSupport :

func MockMiddleware

func MockMiddleware(execFn MiddlewareExecFn) (m route.Middleware)

MockMiddleware :

func MockRequestContext

func MockRequestContext() (r route.RequestContext)

MockRequestContext :

func MockRouteHandler

func MockRouteHandler(bind BindFn, exec ExecuteFn) (h route.HandlerGenerator)

MockRouteHandler :

func MockShutdown

func MockShutdown(srv *netHttp.Server) (err error)

MockShutdown :

func MockUpgradeContext

func MockUpgradeContext(ctx *http.RequestContext) websocket.UpgradeContext

MockUpgradeContext :

func MockWSClient

func MockWSClient() (c *websocket.Client)

MockWSClient :

func MockWSServer

func MockWSServer(container service.Container) (s *websocket.Server)

MockWSServer :

func MockWsConnection

func MockWsConnection(container service.Container) (c *websocket.Connection)

MockWsConnection :

func TestAddResult

func TestAddResult(c *http.Client, url string, data interface{}, expected string) (err error)

TestAddResult :

func TestDeleteResult

func TestDeleteResult(c *http.Client, url string, expected string) (err error)

TestDeleteResult :

func TestGetResult

func TestGetResult(c *http.Client, url string, expected string) (err error)

TestGetResult :

func TestStatusCode

func TestStatusCode(c *http.Client, url string, expected int) (err error)

TestStatusCode :

func TestUpdateResult

func TestUpdateResult(c *http.Client, url string, data interface{}, expected string) (err error)

TestUpdateResult :

Types

type AuthFn

type AuthFn func(r route.Request) bool

AuthFn :

type BindFn

type BindFn func(i interface{}, r route.Request) error

BindFn :

type ExecuteFn

type ExecuteFn func() (data interface{}, err error)

ExecuteFn :

type MiddlewareExecFn

type MiddlewareExecFn func(ctx route.RequestContext) (cancel bool, err error)

MiddlewareExecFn :

type MockResponseWriter

type MockResponseWriter struct {
}

MockResponseWriter :

func (*MockResponseWriter) Header

func (m *MockResponseWriter) Header() netHttp.Header

Header :

func (*MockResponseWriter) Write

func (m *MockResponseWriter) Write(b []byte) (int, error)

Write :

Example
Output:

test write

func (*MockResponseWriter) WriteHeader

func (m *MockResponseWriter) WriteHeader(statusCode int)

WriteHeader :

Example
Output:

200

type RouteHandler

type RouteHandler struct {
	BindFn    BindFn
	ExecuteFn ExecuteFn
}

RouteHandler :

func (*RouteHandler) Bind

func (h *RouteHandler) Bind(i interface{}, r route.Request) error

Bind :

func (*RouteHandler) Execute

func (h *RouteHandler) Execute() (data interface{}, err error)

Execute :

type UpgradeContext

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

UpgradeContext :

func (*UpgradeContext) HTTPContext

func (muc *UpgradeContext) HTTPContext() (ctx *websocket.HTTPContext)

HTTPContext :

func (*UpgradeContext) Language

func (muc *UpgradeContext) Language() (lang *language.Tag)

Language :

Jump to

Keyboard shortcuts

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