pgrx

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 19 Imported by: 0

README

pgrx

gpx injector for using with golang groat testing toolkit

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New[T any](all ...Option) integration.Bootstrap[T]

Types

type Container

type Container[T any] struct {
	// contains filtered or unexported fields
}

func (*Container[T]) Injector

func (c *Container[T]) Injector(t *testing.T, to T) T

type DB

type DB interface {
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
}

type Migrator

type Migrator func(ctx context.Context, migratorConfig MigratorConfig) error

func PlainMigrator

func PlainMigrator(fs afero.Fs, path string) (Migrator, error)

type MigratorConfig

type MigratorConfig struct {
	DBName   string
	Pool     DB
	Path     string
	UserName string
}

type Option

type Option func(*config)

func WithContainerImage

func WithContainerImage(image string) Option

WithContainerImage override initial container image for run postgresql instance, by default using value 'postgres:16'.

func WithContainerImageEnv

func WithContainerImageEnv(env string) Option

WithContainerImageEnv override ENV contained container image name, by default using GROAT_I9N_PG_IMAGE

func WithDBName

func WithDBName(dbName string) Option

WithDBName override the initial database for check correct migrationsPath process by default using value 'test'.

func WithDeadline

func WithDeadline(deadline time.Duration) Option

WithDeadline override the initial timeout for bootstrap container, by default used 5 seconds deadline.

func WithFileSystem

func WithFileSystem(fs afero.Fs) Option

func WithMigrationsPath

func WithMigrationsPath(path string) Option

WithMigrationsPath set default path to migrations files

func WithMigrator

func WithMigrator(migrator Migrator) Option

WithMigrator override default migration func for pgx pool by default used plain sql files in directory

func WithPassword

func WithPassword(password string) Option

WithPassword override the initial password of the user to be created when the container starts as superuser by default using value 'test'.

func WithPoolMaxConnections

func WithPoolMaxConnections(maxCons int32) Option

WithPoolMaxConnections override default number of pgx pool max connections by default used 8.

func WithPoolMaxIdleTime

func WithPoolMaxIdleTime(maxIdleTime time.Duration) Option

WithPoolMaxIdleTime override default number of pgx pool min connections by default used one minute

func WithPoolMinConnections

func WithPoolMinConnections(minCons int32) Option

WithPoolMinConnections override default number of pgx pool min connections by default used 2

func WithUserName

func WithUserName(userName string) Option

WithUserName override initial username of the user to be created when the container starts. By default, using value 'test'.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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