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 org.testcontainers.containers.ComposeContainer
import zio.testcontainers._

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