test

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTestError = errors.New("test error")

ErrTestError is a test error.

Functions

func MustCreateEchoContext

func MustCreateEchoContext(
	echoLogger *zerolog.Logger,
	request *http.Request,
	responseWriter http.ResponseWriter,
) echo.Context

MustCreateEchoContext creates an echo context with the given logger and request and response writer.

func MustCreateEchoContextAndResponseWriter

func MustCreateEchoContextAndResponseWriter(
	echoLogger *zerolog.Logger,
	method string,
	target string,
	body interface{},
) (
	echo.Context,
	*httptest.ResponseRecorder,
)

MustCreateEchoContextAndResponseWriter is a convenience function combining MustCreateEchoContext and MustCreateRequestAndResponseWriter when access to the request is not needed.

func MustCreateRequestAndResponseWriter

func MustCreateRequestAndResponseWriter(
	method string,
	target string,
	body interface{},
) (
	*http.Request,
	*httptest.ResponseRecorder,
)

MustCreateRequestAndResponseWriter creates a http request and a response writer in form of a response recorder. Fails matching in tests, when an error occures.

func MustMockGorm

func MustMockGorm(gormLogger *zerolog.Logger) (*sql.DB, sqlmock.Sqlmock, *gorm.DB)

MustMockGorm creates SQL mock and connects gorm to the mock. Fails matching in tests, when an error occures.

func MustSetupLogging

func MustSetupLogging(loglevel zerolog.Level) (*zerolog.Logger, *zerolog.Logger, *zerolog.Logger)

MustSetupLogging creates child loggers for echo, gorm and handlers.

func Ptr

func Ptr[T any](value T) *T

Ptr returns a pointer to the value. This is used for testing when defining values in code and they need to be a pointer for structs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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