View Source Testcontainers.PostgresContainer (testcontainers v1.11.6)

Provides functionality for creating and managing Postgres container configurations.

Summary

Functions

Returns the connection parameters to connect to the database from the host machine.

Retrieves the default Docker image for the Postgres container.

Retrieves the default Docker image including tag for the Postgres container.

Retrieves the default exposed port for the Postgres container.

Creates a new PostgresContainer struct with default configurations.

Returns the port on the host machine where the Postgres container is listening.

Set the regular expression to check the image validity.

Overrides the default database used for the Postgres container.

Overrides the default image used for the Postgres container.

Overrides the default password used for the Postgres container.

Overrides the default port used for the Postgres container.

Set the reuse flag to reuse the container if it is already running.

Overrides the default user used for the Postgres container.

Overrides the default wait timeout used for the Postgres container.

Functions

Link to this function

connection_parameters(container)

View Source

Returns the connection parameters to connect to the database from the host machine.

Retrieves the default Docker image for the Postgres container.

Link to this function

default_image_with_tag()

View Source

Retrieves the default Docker image including tag for the Postgres container.

Retrieves the default exposed port for the Postgres container.

Creates a new PostgresContainer struct with default configurations.

Returns the port on the host machine where the Postgres container is listening.

Link to this function

with_check_image(config, check_image)

View Source

Set the regular expression to check the image validity.

Link to this function

with_database(config, database)

View Source

Overrides the default database used for the Postgres container.

Examples

iex> config = PostgresContainer.new()
iex> new_config = PostgresContainer.with_database(config, "another-database")
iex> new_config.database
"another-database"
Link to this function

with_image(config, image)

View Source

Overrides the default image used for the Postgres container.

Examples

iex> config = PostgresContainer.new()
iex> new_config = PostgresContainer.with_image(config, "postgres:12")
iex> new_config.image
"postgres:12"
Link to this function

with_password(config, password)

View Source

Overrides the default password used for the Postgres container.

Examples

iex> config = PostgresContainer.new()
iex> new_config = PostgresContainer.with_password(config, "another-password")
iex> new_config.password
"another-password"
Link to this function

with_persistent_volume(config, persistent_volume)

View Source

Callback implementation for Testcontainers.DatabaseBehaviour.with_persistent_volume/2.

Overrides the default port used for the Postgres container.

Note: this will not change what port the docker container is listening to internally.

Examples

iex> config = PostgresContainer.new()
iex> new_config = PostgresContainer.with_port(config, 2345)
iex> new_config.port
2345
Link to this function

with_reuse(config, reuse)

View Source

Set the reuse flag to reuse the container if it is already running.

Overrides the default user used for the Postgres container.

Examples

iex> config = PostgresContainer.new()
iex> new_config = PostgresContainer.with_user(config, "another-user")
iex> new_config.user
"another-user"
Link to this function

with_wait_timeout(config, wait_timeout)

View Source

Overrides the default wait timeout used for the Postgres container.

Note: this timeout will be used for each individual wait strategy.

Examples

iex> config = PostgresContainer.new()
iex> new_config = PostgresContainer.with_wait_timeout(config, 8000)
iex> new_config.wait_timeout
8000