Documentation
¶
Index ¶
- func GetPool(tb testing.TB, migrationsDir string, opt ...Option) *pgxpool.Pool
- type Logger
- type Migrator
- type MigratorFactory
- type Option
- func WithDatabase(database string) Option
- func WithDockerImage(dockerImage string) Option
- func WithDockerPortMapping(dockerPortMapping string) Option
- func WithDockerSocketEndpoint(dockerSocketEndpoint string) Option
- func WithForceDockerMode() Option
- func WithHost(host string) Option
- func WithLogger(logger Logger) Option
- func WithMigratorFactory(migratorFactory MigratorFactory) Option
- func WithPassword(password string) Option
- func WithPort(port string) Option
- func WithRetryTimeout(retryTimeout time.Duration) Option
- func WithUser(user string) Option
- type TestDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Migrator ¶ added in v1.2.0
Migrator interface for applying migrations.
func GolangMigrateFactory ¶ added in v1.2.0
GolangMigrateFactory creates a new migrator for https://github.com/golang-migrate/migrate.
func GooseMigratorFactory ¶ added in v1.2.0
GooseMigratorFactory creates a new migrator for https://github.com/pressly/goose.
type MigratorFactory ¶ added in v1.2.0
MigratorFactory creates a new migrator.
type Option ¶
type Option func(*testDBOptions)
Option option for creating a test database.
func WithDatabase ¶
WithDatabase sets the database name. The default is a randomly generated name.
func WithDockerImage ¶
WithDockerImage sets the name of the postgres image from https://hub.docker.com/_/postgres when running locally in docker. The default is latest.
func WithDockerPortMapping ¶
WithDockerPortMapping sets the port for mapping postgres to the host when running locally in docker. The default is 5433.
func WithDockerSocketEndpoint ¶ added in v1.1.0
WithDockerSocketEndpoint sets the docker socket endpoint for connecting to the docker daemon.
func WithForceDockerMode ¶
func WithForceDockerMode() Option
WithForceDockerMode forces the tests to run in docker.
func WithLogger ¶ added in v1.2.0
WithLogger sets the logger for the test database.
func WithMigratorFactory ¶ added in v1.2.0
func WithMigratorFactory(migratorFactory MigratorFactory) Option
WithMigratorFactory sets the migrator factory for the test database. The default is goose.
func WithPassword ¶
WithPassword sets the password. The default is "secret".
func WithRetryTimeout ¶
WithRetryTimeout sets the timeout for connecting to the database. The default is 30 seconds.
type TestDB ¶
type TestDB struct {
// contains filtered or unexported fields
}
TestDB creates a connection to a temporary test cluster databasepg, allows you to deploy migrations on it and run tests.
func (*TestDB) MigrationsUp ¶
MigrationsUp applies migrations to the database.