testcontainers_gleam/integration

Utilities for running testcontainers integration tests.

Provides a test runner with per-test timeouts suitable for container startup, and a guard function to skip tests when Docker is not available.

Usage

Replace gleeunit.main() with integration.main() in your test entry point, and use integration.guard() to gate individual tests behind the TESTCONTAINERS_INTEGRATION_TESTS environment variable:

import testcontainers_gleam/integration

pub fn main() {
  integration.main()
}

pub fn redis_test() {
  use <- integration.guard()
  // ... start container, run assertions ...
}

Values

pub fn guard(test_fn: fn() -> Nil) -> Nil

Gate a test behind the TESTCONTAINERS_INTEGRATION_TESTS environment variable. When the variable is not set, the test body is skipped and Nil is returned.

Examples

pub fn redis_test() {
  use <- integration.guard()
  // ... start container, run assertions ...
}
pub fn main() -> Nil

Run all tests with a 600-second per-test timeout.

Automatically sets TESTCONTAINERS_RYUK_DISABLED=1 so the Ryuk sidecar container is not started. This is a drop-in replacement for gleeunit.main().

Examples

import testcontainers_gleam/integration

pub fn main() {
  integration.main()
}
pub fn main_with_timeout(
  timeout_seconds timeout_seconds: Int,
) -> Nil

Run all tests with a custom per-test timeout in seconds.

Automatically sets TESTCONTAINERS_RYUK_DISABLED=1 so the Ryuk sidecar container is not started.

Examples

import testcontainers_gleam/integration

pub fn main() {
  integration.main_with_timeout(120)
}
Search Document