Documentation
¶
Index ¶
- Variables
- func GIFHeader(width, height int) []byte
- func NewNoopTask() worker.Task
- func UniformGrayPNG(width, height, bitDepth int, transparent bool) []byte
- func UniformPNG(width, height int) []byte
- type Server
- func (s *Server) AddCookie(name string, value string) *Server
- func (s *Server) AddHeader(name string, value string) *Server
- func (s *Server) AddParam(name string, value any) *Server
- func (s *Server) AsUser(user *entity.User) *Server
- func (s *Server) Engine() *web.Engine
- func (s *Server) Execute(handler web.HandlerFunc) (int, *httptest.ResponseRecorder)
- func (s *Server) ExecuteAsJSON(handler web.HandlerFunc) (int, *jsonq.Query)
- func (s *Server) ExecuteAsPage(handler web.HandlerFunc) (int, *web.Props)
- func (s *Server) ExecutePost(handler web.HandlerFunc, body string) (int, *httptest.ResponseRecorder)
- func (s *Server) ExecutePostAsJSON(handler web.HandlerFunc, body string) (int, *jsonq.Query)
- func (s *Server) OnTenant(tenant *entity.Tenant) *Server
- func (s *Server) Use(middleware web.MiddlewareFunc) *Server
- func (s *Server) WithURL(fullURL string) *Server
- type Worker
Constants ¶
This section is empty.
Variables ¶
var AryaStark *entity.User
AryaStark is a mocked user (visitor)
var AvengersTenant *entity.Tenant
AvengersTenant is a mocked tenant
var DemoTenant *entity.Tenant
DemoTenant is a mocked tenant
var JonSnow *entity.User
JonSnow is a mocked user (administrator)
Functions ¶
func GIFHeader ¶ added in v0.38.0
GIFHeader returns the header of a GIF with the given logical screen dimensions (max 65535). It contains no image data: enough for image.DecodeConfig, but not for image.Decode.
func NewNoopTask ¶ added in v0.11.0
NewNoopTask returns a worker task that does nothing
func UniformGrayPNG ¶ added in v0.38.0
UniformGrayPNG is like UniformPNG, with the given bit depth (1, 2, 4, 8 or 16), and a tRNS chunk (making one gray level transparent) when transparent is true.
func UniformPNG ¶ added in v0.38.0
UniformPNG returns a valid 1-bit grayscale PNG of the given dimensions where every pixel is black. It is streamed row by row, so generating it never allocates the full image in memory. Large dimensions compress extremely well, which makes this useful for building "decompression bomb" images in tests (e.g. 12000x12000 is only a few KB). Results are cached, callers must not modify the returned slice.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a HTTP server wrapper for testing purpose
func NewSingleTenantServer ¶
func NewSingleTenantServer() *Server
NewSingleTenantServer creates a new multitenant test server
func (*Server) Execute ¶
func (s *Server) Execute(handler web.HandlerFunc) (int, *httptest.ResponseRecorder)
Execute given handler and return response
func (*Server) ExecuteAsJSON ¶
ExecuteAsJSON given handler and return json response
func (*Server) ExecuteAsPage ¶ added in v0.20.0
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
ExecutePostAsJSON executes given handler as POST and return json response
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) WithBaseURL ¶ added in v0.14.0
WithBaseURL set current context baseURL