mock

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AryaStark *entity.User

AryaStark is a mocked user (visitor)

View Source
var AvengersTenant *entity.Tenant

AvengersTenant is a mocked tenant

View Source
var DemoTenant *entity.Tenant

DemoTenant is a mocked tenant

View Source
var JonSnow *entity.User

JonSnow is a mocked user (administrator)

Functions

func NewNoopTask added in v0.11.0

func NewNoopTask() worker.Task

NewNoopTask returns a worker task that does nothing

Types

type Server

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

Server is a HTTP server wrapper for testing purpose

func NewServer

func NewServer() *Server

NewServer creates a new server for HTTP testing

func NewSingleTenantServer

func NewSingleTenantServer() *Server

NewSingleTenantServer creates a new multitenant test server

func (*Server) AddCookie added in v0.5.0

func (s *Server) AddCookie(name string, value string) *Server

AddCookie add key-value to current context cookies

func (*Server) AddHeader added in v0.5.0

func (s *Server) AddHeader(name string, value string) *Server

AddHeader add key-value to current context headers

func (*Server) AddParam added in v0.7.0

func (s *Server) AddParam(name string, value any) *Server

AddParam to current context route parameters

func (*Server) AsUser added in v0.5.0

func (s *Server) AsUser(user *entity.User) *Server

AsUser set current context user

func (*Server) Engine added in v0.11.0

func (s *Server) Engine() *web.Engine

Engine returns current engine from mocked server

func (*Server) Execute

func (s *Server) Execute(handler web.HandlerFunc) (int, *httptest.ResponseRecorder)

Execute given handler and return response

func (*Server) ExecuteAsJSON

func (s *Server) ExecuteAsJSON(handler web.HandlerFunc) (int, *jsonq.Query)

ExecuteAsJSON given handler and return json response

func (*Server) ExecuteAsPage added in v0.20.0

func (s *Server) ExecuteAsPage(handler web.HandlerFunc) (int, *web.Props)

ExecuteAsPage given handler and return page props

func (*Server) ExecutePost

func (s *Server) ExecutePost(handler web.HandlerFunc, body string) (int, *httptest.ResponseRecorder)

ExecutePost executes given handler as POST and return response

func (*Server) ExecutePostAsJSON added in v0.6.0

func (s *Server) ExecutePostAsJSON(handler web.HandlerFunc, body string) (int, *jsonq.Query)

ExecutePostAsJSON executes given handler as POST and return json response

func (*Server) OnTenant added in v0.5.0

func (s *Server) OnTenant(tenant *entity.Tenant) *Server

OnTenant set current context tenant

func (*Server) Use

func (s *Server) Use(middleware web.MiddlewareFunc) *Server

Use adds a new middleware to pipeline

func (*Server) WithURL added in v0.5.0

func (s *Server) WithURL(fullURL string) *Server

WithURL set current context Request URL

type Worker added in v0.10.0

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

Worker is fake wrapper for background worker

func NewWorker added in v0.10.0

func NewWorker() *Worker

NewWorker creates a new worker for worker testing

func (*Worker) AsUser added in v0.10.0

func (w *Worker) AsUser(user *entity.User) *Worker

AsUser set current context user

func (*Worker) Execute added in v0.10.0

func (w *Worker) Execute(task worker.Task) error

Execute given task with current context

func (*Worker) OnTenant added in v0.10.0

func (w *Worker) OnTenant(tenant *entity.Tenant) *Worker

OnTenant set current context tenant

func (*Worker) WithBaseURL added in v0.14.0

func (w *Worker) WithBaseURL(baseURL string) *Worker

WithBaseURL set current context baseURL

Jump to

Keyboard shortcuts

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