testcontainers_gleam/mysql

MySQL container configuration.

Wraps Testcontainers.MySqlContainer to provide typed builders for a MySQL 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/mysql

let config = mysql.new()
let container = mysql.build(config)
let assert Ok(running) = testcontainers_gleam.start_container(container)
let params = mysql.connection_parameters(running)

Types

Opaque type wrapping the Elixir keyword list returned by MySqlContainer.connection_parameters/1.

pub type ConnectionParameters

Configuration for a MySQL container.

pub type MysqlConfig

Values

pub fn build(config: MysqlConfig) -> container.Container

Build a Container from this MySQL configuration.

pub fn connection_parameters(
  container: container.Container,
) -> ConnectionParameters

Get the connection parameters as an Elixir keyword list.

pub fn default_image() -> String

Get the default Docker image name (without tag).

pub fn default_port() -> Int

Get the default exposed port (3306).

pub fn new() -> MysqlConfig

Create a new MySQL container configuration with defaults.

Default image: mysql:8, user/password/database: "test", port: 3306, timeout: 180s.

pub fn port(container: container.Container) -> Int

Get the host-mapped port for the MySQL container.

pub fn with_check_image(
  config: MysqlConfig,
  pattern: String,
) -> MysqlConfig

Set the regex pattern to validate the image name.

pub fn with_database(
  config: MysqlConfig,
  database: String,
) -> MysqlConfig

Override the database name (default "test").

pub fn with_image(
  config: MysqlConfig,
  image: String,
) -> MysqlConfig

Override the Docker image.

pub fn with_password(
  config: MysqlConfig,
  password: String,
) -> MysqlConfig

Override the database password (default "test").

pub fn with_persistent_volume(
  config: MysqlConfig,
  path: String,
) -> MysqlConfig

Attach a persistent volume at the given path.

pub fn with_port(config: MysqlConfig, port: Int) -> MysqlConfig

Override the exposed port (default 3306).

pub fn with_reuse(
  config: MysqlConfig,
  reuse: Bool,
) -> MysqlConfig

Enable or disable container reuse across test runs.

pub fn with_user(
  config: MysqlConfig,
  user: String,
) -> MysqlConfig

Override the database user (default "test").

pub fn with_wait_timeout(
  config: MysqlConfig,
  timeout: Int,
) -> MysqlConfig

Override the wait timeout in milliseconds (default 180000).

Search Document