diff --git a/build.sbt b/build.sbt index 3b41ad1..494acfe 100644 --- a/build.sbt +++ b/build.sbt @@ -28,6 +28,7 @@ lazy val commonSettings: List[Def.Setting[_]] = DecentScala.decentScalaSettings ) ), testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"), + scalacOptions -= "-Xsource:3", // we cross-build for 2.11 too! missinglinkExcludedDependencies ++= List( moduleFilter(organization = "org.slf4j", name = "slf4j-api"), moduleFilter(organization = "org.testcontainers", name = "testcontainers") diff --git a/src/main/scala/zio/testcontainers/ZIOTestcontainers.scala b/src/main/scala/zio/testcontainers/ZIOTestcontainers.scala index e073d65..f0bdf44 100644 --- a/src/main/scala/zio/testcontainers/ZIOTestcontainers.scala +++ b/src/main/scala/zio/testcontainers/ZIOTestcontainers.scala @@ -3,7 +3,7 @@ package zio.testcontainers import com.dimafeng.testcontainers.{DockerComposeContainer, SingleContainer} import org.testcontainers.containers.{GenericContainer => JavaGenericContainer} import org.testcontainers.lifecycle.Startable -import zio.{RIO, RLayer, Scope, Tag, UIO, ZIO, ZLayer} +import zio.{Scope, Tag, UIO, ULayer, URIO, ZIO, ZLayer} object ZIOTestcontainers { @@ -21,13 +21,13 @@ object ZIOTestcontainers { port <- ZIO.succeed(container.mappedPort(port)) } yield (host, port) - def toZIO[T <: Startable](startable: T): RIO[Scope, T] = { + def toZIO[T <: Startable](startable: T): URIO[Scope, T] = { val acquire = ZIO.succeedBlocking(startable.start()).as(startable) val release = (container: T) => ZIO.succeedBlocking(container.stop()) ZIO.acquireRelease(acquire)(release) } - def toLayer[T <: Startable: Tag](container: T): RLayer[Scope, T] = - ZLayer.fromZIO(toZIO(container)) + def toLayer[T <: Startable: Tag](container: T): ULayer[T] = + ZLayer.scoped(toZIO(container)) } diff --git a/src/main/scala/zio/testcontainers/package.scala b/src/main/scala/zio/testcontainers/package.scala index 1fb3c4d..3a1b6a3 100644 --- a/src/main/scala/zio/testcontainers/package.scala +++ b/src/main/scala/zio/testcontainers/package.scala @@ -24,17 +24,17 @@ package object testcontainers { implicit final class StartableOps[T <: Startable](private val self: T) extends AnyVal { - def toZIO: RIO[Scope, T] = + def toZIO: URIO[Scope, T] = ZIOTestcontainers.toZIO(self) - def toLayer(implicit ev: Tag[T]): RLayer[Scope, T] = + def toLayer(implicit ev: Tag[T]): ULayer[T] = ZIOTestcontainers.toLayer(self) } implicit final class ZLayerTestContainerOps[T <: Startable](private val self: ZLayer.type) extends AnyVal { - def fromTestContainer(startable: T)(implicit ev: Tag[T]): RLayer[Scope, T] = + def fromTestContainer(startable: T)(implicit ev: Tag[T]): ULayer[T] = ZIOTestcontainers.toLayer(startable) }