Skip to content

Import/1.0.0#1

Merged
lupodevelop merged 15 commits into
mainfrom
import/1.0.0
Apr 28, 2026
Merged

Import/1.0.0#1
lupodevelop merged 15 commits into
mainfrom
import/1.0.0

Conversation

@lupodevelop

Copy link
Copy Markdown
Owner

This pull request introduces the initial public release of testcontainer_formulas version 1.0.0, providing ready-to-use, highly customizable formulas for common services (Postgres, Redis, MongoDB, MySQL, RabbitMQ) on top of the Gleam testcontainer library.

Major new features and formulas:

  • New formulas and builders: Added formulas for MongoDB, MySQL, and RabbitMQ, each with a comprehensive set of builder functions (e.g., with_image/2, with_database/2, with_username/2, with_password/2, network composition, and more). Also added Redis authentication builders and network-name variants for Postgres and Redis.
  • Mongo formula implementation: Introduced testcontainer_formulas/mongo.gleam with a typed output, sensible defaults, and full support for builder pattern configuration and network composition.

Other improvements:

  • Percent-encoded connection URLs: All formulas now percent-encode credentials and path segments in connection URLs to prevent DSN breakage with special characters.
  • Project configuration: Added gleam.toml with dependencies, version, and metadata for Hex publishing.

Add Gleam formulas under src/testcontainer_formulas for Mongo, MySQL, Postgres, RabbitMQ and Redis. Each module provides a Config builder (new/with_*) and a formula() that builds a testcontainer spec which exposes ports, sets env/credentials or command, supports network and container naming, and composes wait strategies. The formulas return typed container records including connection URLs, host/port(s) and relevant credentials/database info. Default images: mongo:7, mysql:8.4, postgres:16-alpine, rabbitmq:3-management, redis:7-alpine.
Introduce comprehensive tests for testcontainer formulas: adds formula_contract helpers and two test suites (integration and unit). The integration tests (guarded by TESTCONTAINER_FORMULAS_INTEGRATION) exercise Postgres, Redis (including password), MySQL, RabbitMQ and Mongo formulas and verify endpoint contracts, container readiness via exec, and URL prefixes/ports. The unit tests include builder smoke tests, secret redaction checks (ensure passwords aren't revealed in inspect), and numerous URL-encoding checks for credentials, databases, and vhosts using a synthetic_container helper.
Introduce three new docs: quickstart (usage examples for Postgres, Redis, MySQL, Mongo, RabbitMQ, and shared-network stacks), testing-model (unit vs integration contract guidance and how to run integration tests), and writing-formulas (minimal formula shape, design guidelines, and suggested builders). These pages help contributors get started, write consistent formulas, and run/verify integration tests.
Expand README with badges, installation instructions, a quick example, available formulas, documentation links, and license information. Add a Gleam-generated manifest.toml listing project dependencies and requirements, including a local testcontainer package reference for build tooling.
Add a new CHANGELOG.md documenting the 1.0.0 release and prior 0.1.0. Notes include added docs (quickstart, writing-formulas, testing-model), new formulas (mongo, mysql, rabbitmq), numerous builders for Mongo/MySQL/RabbitMQ/Redis, network-name builders, and test/contract changes. Also documents behavioral changes (percent-encoding credentials in DSNs, updated Mongo wait strategy), README trimming, and removal of RabbitMQ's custom vhost encoder. Includes 0.1.0 entry listing initial Postgres/Redis formulas and MIT license.
Replace the local path dependency for testcontainer with a version range in gleam.toml and remove the CI steps that checked out the sibling repository in .github/workflows/test.yml. The manifest was updated accordingly to reflect the published package so the workflow no longer needs a local checkout of ../testcontiner.
Apply formatting and readability improvements across formulas and tests:

- Use underscored numeric literals for port constants (27017 -> 27_017, 15672 -> 15_672) in mongo and rabbitmq formulas.
- Reformat rabbitmq function signature, argument lists, and string concatenation for clarity; wrap container.host_port call arguments.
- Reorder/import spacing in test/formula_contract.gleam.
- Reflow testcontainer.exec command argument lists in integration tests to consistent single-line or multi-line arrays.
Bump testcontainer dependency to 1.0.1 in manifest (updated checksum).

In src/testcontainer_formulas/mongo.gleam replace wait.log(...) with wait.log_times("Waiting for connections", 2) and update docs/comments. This matches the second emission of the "Waiting for connections" line (post-bootstrap restart when --auth is enabled) to avoid racing the auth bootstrap which could cause "Authentication failed" errors. Also adjust the composed wait strategy to include the new log_times check.
Replace fuzzy log matching of "ready for connections" with the mysqld-specific message id "MY-010931" so the wait strategy reliably matches the final TCP-ready server (after init scripts). Also update the integration test to pass --get-server-public-key to mysqladmin so clients using the default caching_sha2_password plugin can fetch the server RSA public key over plain TCP and avoid "Authentication requires secure connection" on first connect.
@lupodevelop lupodevelop merged commit a339f0a into main Apr 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant