testcontainers_gleam/postgres
PostgreSQL container configuration.
Wraps Testcontainers.PostgresContainer to provide typed builders
for a PostgreSQL container. Use new to create a default configuration,
customize with with_* functions, then build to get a Container.
Example
import testcontainers_gleam
import testcontainers_gleam/postgres
let config = postgres.new()
let container = postgres.build(config)
let assert Ok(running) = testcontainers_gleam.start_container(container)
let params = postgres.connection_parameters(running)
Types
Opaque type wrapping the Elixir keyword list returned by
PostgresContainer.connection_parameters/1.
pub type ConnectionParameters
Configuration for a PostgreSQL container.
pub type PostgresConfig
Values
pub fn build(config: PostgresConfig) -> container.Container
Build a Container from this PostgreSQL configuration.
pub fn connection_parameters(
container: container.Container,
) -> ConnectionParameters
Get the connection parameters as an Elixir keyword list.
pub fn new() -> PostgresConfig
Create a new PostgreSQL container configuration with defaults.
Default image: postgres:15-alpine, user/password/database: "test",
port: 5432, timeout: 60s.
pub fn port(container: container.Container) -> Int
Get the host-mapped port for the PostgreSQL container.
pub fn with_check_image(
config: PostgresConfig,
pattern: String,
) -> PostgresConfig
Set the regex pattern to validate the image name.
pub fn with_database(
config: PostgresConfig,
database: String,
) -> PostgresConfig
Override the database name (default "test").
pub fn with_image(
config: PostgresConfig,
image: String,
) -> PostgresConfig
Override the Docker image.
pub fn with_password(
config: PostgresConfig,
password: String,
) -> PostgresConfig
Override the database password (default "test").
pub fn with_persistent_volume(
config: PostgresConfig,
path: String,
) -> PostgresConfig
Attach a persistent volume at the given path.
pub fn with_port(
config: PostgresConfig,
port: Int,
) -> PostgresConfig
Override the exposed port (default 5432).
pub fn with_reuse(
config: PostgresConfig,
reuse: Bool,
) -> PostgresConfig
Enable or disable container reuse across test runs.
pub fn with_user(
config: PostgresConfig,
user: String,
) -> PostgresConfig
Override the database user (default "test").
pub fn with_wait_timeout(
config: PostgresConfig,
timeout: Int,
) -> PostgresConfig
Override the wait timeout in milliseconds (default 60000).