echotest

package
v5.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadBytes

func LoadBytes(t *testing.T, name string, opts ...loadBytesOpts) []byte

LoadBytes is helper to load file contents relative to current (where test file is) package directory.

func TrimNewlineEnd

func TrimNewlineEnd(bytes []byte) []byte

TrimNewlineEnd instructs LoadBytes to remove `\n` from the end of loaded file.

Types

type ContextConfig

type ContextConfig struct {
	// Request will be used instead of default `httptest.NewRequest(http.MethodGet, "/", nil)`
	Request *http.Request

	// Response will be used instead of default `httptest.NewRecorder()`
	Response *httptest.ResponseRecorder

	// QueryValues will be set as Request.URL.RawQuery value
	QueryValues url.Values

	// Headers will be set as Request.Header value
	Headers http.Header

	// PathValues initializes context.PathValues with given value.
	PathValues echo.PathValues

	// RouteInfo initializes context.RouteInfo() with given value
	RouteInfo *echo.RouteInfo

	// FormValues creates form-urlencoded form out of given values. If there is no
	// `content-type` header it will be set to `application/x-www-form-urlencoded`
	// In case Request was not set the Request.Method is set to `POST`
	//
	// FormValues, MultipartForm and JSONBody are mutually exclusive.
	FormValues url.Values

	// MultipartForm creates multipart form out of given value. If there is no
	// `content-type` header it will be set to `multipart/form-data`
	// In case Request was not set the Request.Method is set to `POST`
	//
	// FormValues, MultipartForm and JSONBody are mutually exclusive.
	MultipartForm *MultipartForm

	// JSONBody creates JSON body out of given bytes. If there is no
	// `content-type` header it will be set to `application/json`
	// In case Request was not set the Request.Method is set to `POST`
	//
	// FormValues, MultipartForm and JSONBody are mutually exclusive.
	JSONBody []byte
}

ContextConfig is configuration for creating echo.Context for testing purposes.

func (ContextConfig) ServeWithHandler

func (conf ContextConfig) ServeWithHandler(t *testing.T, handler echo.HandlerFunc, opts ...any) *httptest.ResponseRecorder

ServeWithHandler serves ContextConfig with given handler and returns httptest.ResponseRecorder for response checking

func (ContextConfig) ToContext

func (conf ContextConfig) ToContext(t *testing.T) *echo.Context

ToContext converts ContextConfig to echo.Context

func (ContextConfig) ToContextRecorder

func (conf ContextConfig) ToContextRecorder(t *testing.T) (*echo.Context, *httptest.ResponseRecorder)

ToContextRecorder converts ContextConfig to echo.Context and httptest.ResponseRecorder

type MultipartForm

type MultipartForm struct {
	Fields map[string]string
	Files  []MultipartFormFile
}

MultipartForm is used to create multipart form out of given value

type MultipartFormFile

type MultipartFormFile struct {
	Fieldname string
	Filename  string
	Content   []byte
}

MultipartFormFile is used to create file in multipart form out of given value

Jump to

Keyboard shortcuts

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