Documentation ¶
Index ¶
- Constants
- func BeginTestTX[T any](database bun.IDB, fixtures []T) bun.Tx
- func ClearTestDB(database *bun.DB)
- func FreezeTime(db bun.IDB, date time.Time) error
- func Migrate(database *bun.DB, sqlMigrations embed.FS, formatter formatters.Formatter) error
- func MustRegisterValidation(customValidator *validator.Validate, name string, ...)
- func OpenDB(dsn string) (*bun.DB, func(), error)
- func OpenTestDB(sqlMigrations *embed.FS) (*bun.DB, func(), error)
- func RegisterSortDirection(customValidator *validator.Validate)
- func RestoreTime(db bun.IDB) error
- func RollbackTestTX(transaction bun.Tx)
- func ValidateEnum[T comparable](list ...T) func(fl validator.FieldLevel) bool
- type SortDirection
Constants ¶
const TestDSN = "postgres://test:test@localhost:5432/test?sslmode=disable"
Variables ¶
This section is empty.
Functions ¶
func ClearTestDB ¶
func MustRegisterValidation ¶
func OpenDB ¶
OpenDB automatically configures a bun.DB instance with postgresSQL drivers. It returns the database, along with a closing function, whose execution can be deferred for a graceful shutdown.
func OpenTestDB ¶
OpenTestDB opens a connection to a test DB.
The test DB must be available under the value stored in DSN.
func RegisterSortDirection ¶
func RegisterSortDirection(customValidator *validator.Validate)
RegisterSortDirection registers the SortDirection type with a validator.
func RestoreTime ¶
func RollbackTestTX ¶
func ValidateEnum ¶
func ValidateEnum[T comparable](list ...T) func(fl validator.FieldLevel) bool
ValidateEnum creates a custom validation for go-validator. It checks if the value is part of the enum.
TODO: look for custom errors in v11: https://github.com/go-playground/validator/issues/669
Types ¶
type SortDirection ¶
type SortDirection string
SortDirection controls the direction of the ordering for a particular request. You can use this type with a validator.
const ( SortDirectionNone SortDirection = "" SortDirectionAsc SortDirection = "asc" SortDirectionDesc SortDirection = "desc" )