postgres

package
v0.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithConfigFile

func WithConfigFile(cfg string) testcontainers.CustomizeRequestOption

func WithCustomDocker

func WithCustomDocker(docker testcontainers.FromDockerfile) testcontainers.CustomizeRequestOption

func WithDatabase

func WithDatabase(dbName string) testcontainers.CustomizeRequestOption

WithDatabase sets the initial database to be created when the container starts It can be used to define a different name for the default database that is created when the image is first started. If it is not specified, then the value of WithUser will be used.

func WithImage

func WithImage(image string) testcontainers.CustomizeRequestOption

func WithInitDir

func WithInitDir(dir string) testcontainers.CustomizeRequestOption

func WithInitScript

func WithInitScript(script string, containerName string) testcontainers.CustomizeRequestOption

WithInitScripts sets the init scripts to be run when the container starts

func WithInitScripts

func WithInitScripts(scripts ...string) testcontainers.CustomizeRequestOption

WithInitScripts sets the init scripts to be run when the container starts

func WithPassword

func WithPassword(password string) testcontainers.CustomizeRequestOption

WithPassword sets the initial password of the user to be created when the container starts It is required for you to use the PostgreSQL image. It must not be empty or undefined. This environment variable sets the superuser password for PostgreSQL.

func WithUsername

func WithUsername(user string) testcontainers.CustomizeRequestOption

WithUsername sets the initial username to be created when the container starts It is used in conjunction with WithPassword to set a user and its password. It will create the specified user with superuser power and a database with the same name. If it is not specified, then the default user of postgres will be used.

Types

type PostgresContainer

type PostgresContainer struct {
	testcontainers.Container
	// contains filtered or unexported fields
}

PostgresContainer represents the postgres container type used in the module

func Prepare

func Prepare(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*PostgresContainer, error)

Prepare creates an instance of the postgres container type

func (*PostgresContainer) ConnectionString

func (c *PostgresContainer) ConnectionString(ctx context.Context, args ...string) (string, error)

ConnectionString returns the connection string for the postgres container, using the default 5432 port, and obtaining the host and exposed port from the container. It also accepts a variadic list of extra arguments which will be appended to the connection string. The format of the extra arguments is the same as the connection string format, e.g. "connect_timeout=10" or "application_name=myapp"

func (*PostgresContainer) Port

func (c *PostgresContainer) Port() int

Jump to

Keyboard shortcuts

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