ZIO testcontainers

CI Release
Build Status Release Artifacts

ZIO wrapper for Testcontainers.

"com.github.sideeffffect" %% "zio-testcontainers" % "<version>" % Test

This library comes with toLayer extension method (behind zio.testcontainers._ import) that will turn any TestContainer into a layer that you can use in your tests.

import zio.testcontainers._

lazy val dockerCompose: ULayer[DockerComposeContainer] = ZLayer.fromTestContainer {
  new DockerComposeContainer(
    new File("docker-compose.yml"),
    List(
      ExposedService("mariadb_1", 3306),
      ExposedService("mailhog_1", 1025),
      ExposedService("mailhog_1", 8025),
    )
  )
}
...
lazy val layer = ZLayer.fromZIO {
  for {
    docker <- ZIO.service[DockerComposeContainer]
    (host, port) <- docker.getHostAndPort("mariadb_1")(3306)
    config = ...
  } yield config
}