utils

package
v0.0.0-...-d389d3b Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestDirectoryRoot = dir + "/../../"
)

Functions

func AssertNilOrFail

func AssertNilOrFail(t *testing.T, subject any)

func CreateDatabase

func CreateDatabase(databaseName string, appConfig *config.AppConfig) (string, error)

func Dirname

func Dirname() (string, error)

func DoHTTPRequest

func DoHTTPRequest(t *testing.T, httpHandler http.Handler, request *http.Request, opts ...ExpectOption)

func DoHTTPRequestWithResponse

func DoHTTPRequestWithResponse[T any](
	t *testing.T,
	httpHandler http.Handler,
	request *http.Request,
	response T,
	opts ...ExpectOption,
) T

func DropDatabase

func DropDatabase(databaseName string, appConfig *config.AppConfig) (string, error)

func EncodeToJSON

func EncodeToJSON(t *testing.T, subject any) io.Reader

func Filename

func Filename() (string, error)

func NewHTTPRequest

func NewHTTPRequest(t *testing.T, method string, url string, body io.Reader) *http.Request

func SeedDatabase

func SeedDatabase()

func SuccessOrFailNow

func SuccessOrFailNow[T any](t *testing.T, tester func() (T, error))

func ToDatabaseName

func ToDatabaseName(testFuncName string) string

func TruncateDatabase

func TruncateDatabase(db persistence.Database, config *config.AppConfig) error

func ValueFromOrFail

func ValueFromOrFail[T any](t *testing.T, value T, err error) T

func ValueFromSupplierOrFail

func ValueFromSupplierOrFail[T any](t *testing.T, supplier func() (T, error)) T

Types

type ExpectOption

type ExpectOption func(t *testing.T, response *http.Response)

func ExpectHTTPStatus

func ExpectHTTPStatus(statusCode int) ExpectOption

Jump to

Keyboard shortcuts

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