testutils

package
v0.0.0-...-eddb447 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCanBeContextError

func CheckCanBeContextError(t *testing.T, ctx *gin.Context, target any)

CheckCanBeContextError verifies that the error attached to the context can be matched to the target error. It stops and fails the test otherwise.

func CheckIsContextError

func CheckIsContextError(t *testing.T, ctx *gin.Context, target error)

CheckIsContextErrors verifies that the error attached to the context has the specified value. It stops and fails the test otherwise.

func CheckNoContextErrors

func CheckNoContextErrors(t *testing.T, ctx *gin.Context)

CheckNoContextErrors verifies that there are no errors are attached to the context. If stops and fails the test otherwise.

func Setup

func Setup(migrationsDir string) (*gorm.DB, string, error)

Setup creates a temporary sqlite3 database folder, returning a database connection.

func Teardown

func Teardown(db *gorm.DB, dbname string) error

Teardown closes the sqlite3 database connection, and removes the database file.

Types

type UniqueRand

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

Overwrite rand.Int() to always return unique numbers

func NewUniqueRand

func NewUniqueRand() UniqueRand

func (UniqueRand) Int

func (r UniqueRand) Int() int

func (UniqueRand) Intn

func (r UniqueRand) Intn(n int) int

Jump to

Keyboard shortcuts

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