package testcontainers

All checked builds pass
  1. Overview
  2. Docs
Docker containers for OCaml integration tests

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1.0.tar.gz
md5=63a5c17a6b007f80fc3357592c9893e3
sha512=efaa80c1b8c691b1a5a7caa753091ed5d997fea3a71197749dc576735ece7c05ec9763e1208361fe8579db658eb25fa3d004b67dd31fcdf9a90f25eb95f839c9

Description

TestContainers is an OCaml library that provides lightweight, throwaway instances of databases, message brokers, or any service that runs in a Docker container. Enables reliable integration testing with real services instead of mocks.

README

testcontainers-ocaml

Lightweight, throwaway instances of databases, message brokers, or any service that runs in a Docker container. Enables reliable integration testing with real services instead of mocks.

Installation

opam install testcontainers

Quick Example

open Lwt.Syntax
open Testcontainers_postgres

let () = Lwt_main.run (
  Postgres_container.with_postgres (fun _container conn_str ->
    Printf.printf "PostgreSQL: %s\n" conn_str;
    Lwt.return_unit
  )
)

Running Examples

# Clone the repository
git clone https://github.com/benodiwal/testcontainers_ocaml.git
cd testcontainers_ocaml

# Install dependencies
opam install . --deps-only

# Run examples
dune exec examples/basic_example.exe
dune exec examples/postgres_example.exe
dune exec examples/redis_example.exe
dune exec examples/mysql_example.exe
dune exec examples/mongo_example.exe
dune exec examples/kafka_example.exe
dune exec examples/elasticsearch_example.exe
dune exec examples/localstack_example.exe
dune exec examples/memcached_example.exe
dune exec examples/mockserver_example.exe

Available Modules

Module

Package

Description

PostgreSQL

testcontainers-postgres

PostgreSQL database

MySQL

testcontainers-mysql

MySQL database

MongoDB

testcontainers-mongo

MongoDB database

Redis

testcontainers-redis

Redis cache

RabbitMQ

testcontainers-rabbitmq

RabbitMQ message broker

Kafka

testcontainers-kafka

Apache Kafka (KRaft)

Elasticsearch

testcontainers-elasticsearch

Elasticsearch

LocalStack

testcontainers-localstack

AWS services emulation

Memcached

testcontainers-memcached

Memcached cache

MockServer

testcontainers-mockserver

HTTP mocking

Documentation

Full documentation: https://benodiwal.github.io/testcontainers-ocaml

Requirements

  • OCaml >= 5.0
  • Docker

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

License

Apache-2.0

Dependencies (9)

  1. fmt >= "0.9.0"
  2. logs >= "0.7.0"
  3. uri >= "4.0"
  4. re >= "1.11.0"
  5. yojson >= "2.0"
  6. lwt_ppx >= "2.1.0"
  7. lwt >= "5.7.0"
  8. dune >= "3.20"
  9. ocaml >= "5.0"

Dev Dependencies (1)

  1. odoc with-doc

Optional Dependencies

None

Conflicts

None

Build status

Results of building testcontainers with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.1.0 (this version) n/a n/a good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure