pgtest

package
v0.0.0-...-f8e9dc7 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = errors.New("pgtest")

Functions

func BunDB

func BunDB(t *testing.T) *bun.DB

func BunTx

func BunTx(t *testing.T) *bun.DB

func DB

func DB(t *testing.T) *sql.DB

DB returns a non-transaction *sql.DB. The reason is there is a need for testing stuff that should not be in the same transactions, e.g. when generating current_timestamp, or locking in different connection.

func DSN

func DSN() string

func Expire

func Expire(duration time.Duration) func(*config) error

Expire sets the duration for the docker to hard-kill the postgres image.

func Hook

func Hook(fn func(*sql.DB) error) func(*config) error

func Image

func Image(image string) func(*config) error

func Init

func Init(opts ...Option) func()

func New

func New(t *testing.T, opts ...Option) *testClient

func Tx

func Tx(t *testing.T) *sql.DB

Tx runs everything as a single transaction. The operations will be rollbacked at the end, reducing the need to manually create transactions and rollbacking.

Types

type Option

type Option func(*config) error

Jump to

Keyboard shortcuts

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