Documentation ¶
Overview ¶
nolint: gosec
Index ¶
- func DropAndRecreateDB(dbName string)
- func GetFileRuntimeDirectory() string
- func GetStderr(t *testing.T, dir string) string
- func NewDB(options ...TestDBOption) (*pgxpool.Pool, *sql.DB, error)
- func NewLogger(t *testing.T) *zap.SugaredLogger
- func RandomBool() bool
- func RandomDate() time.Time
- func RandomEmail() string
- func RandomFirstName() string
- func RandomFrom[T any](items []T) T
- func RandomHEXColor() string
- func RandomInt(min, max int) int
- func RandomInt64(min, max int64) int64
- func RandomLastName() string
- func RandomLocalDate() time.Time
- func RandomMoney() int64
- func RandomName() string
- func RandomNameIdentifier(n int, sep string) string
- func RandomString(n int) string
- func Setup()
- type TestDBOption
- type TestDBOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropAndRecreateDB ¶
func DropAndRecreateDB(dbName string)
DropAndRecreateDB drops and recreates a given database.
func GetFileRuntimeDirectory ¶
func GetFileRuntimeDirectory() string
Returns the directory of the file this function lives in.
func NewDB ¶
NewDB returns a new testing Postgres pool with up-to-date migrations. It is shared within the test suite package. Panics on any error encountered.
func RandomFrom ¶
func RandomFrom[T any](items []T) T
RandomFrom selects a random item from a list. Assumes the list is not empty.
func RandomHEXColor ¶
func RandomHEXColor() string
RandomHEXColor generates a random color in hexadecimal format (#RRGGBB).
func RandomInt64 ¶
RandomInt64 generates a random int64 between min and max.
func RandomNameIdentifier ¶
RandomNameIdentifier generates a random name identifier, such as eminently-sincere-mollusk-aksticpemgicjrtb. Prefix count is configurable via n.
func RandomString ¶
RandomString generates a random string of length n.
Types ¶
type TestDBOption ¶
type TestDBOption func(*TestDBOptions)
func WithMigrations ¶
func WithMigrations() TestDBOption
WithMigrations runs migrations on top of the database.
type TestDBOptions ¶
type TestDBOptions struct {
WithMigrations bool
}