From 7768ca584354416adcaf4becb591936c84e34b99 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 7 Nov 2023 18:14:10 +0000 Subject: [PATCH 1/3] Update zio, zio-streams to 2.0.19 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index eb77bb6e..5470f86e 100644 --- a/build.sbt +++ b/build.sbt @@ -137,8 +137,8 @@ lazy val zio = project name := "colibri-zio", libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % "2.5.0", - "dev.zio" %%% "zio" % "2.0.6", - "dev.zio" %%% "zio-streams" % "2.0.6", + "dev.zio" %%% "zio" % "2.0.19", + "dev.zio" %%% "zio-streams" % "2.0.19", ), ) From 7517edc032c8844b03489e0f5d887f01cbdabbd0 Mon Sep 17 00:00:00 2001 From: johannes karoff Date: Sun, 12 Nov 2023 19:51:28 +0100 Subject: [PATCH 2/3] test --- .../test/scala/colibri/ObservableSpec.scala | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/zio/src/test/scala/colibri/ObservableSpec.scala b/zio/src/test/scala/colibri/ObservableSpec.scala index 6c9c230b..d63c3e65 100644 --- a/zio/src/test/scala/colibri/ObservableSpec.scala +++ b/zio/src/test/scala/colibri/ObservableSpec.scala @@ -1,12 +1,23 @@ package colibri +import cats.effect.IO +import cats.effect.unsafe import zio._ -// import zio.stream.ZStream import colibri.ext.zio._ import org.scalatest.matchers.should.Matchers import org.scalatest.flatspec.AsyncFlatSpec +import java.util.concurrent.TimeUnit + class ObservableSpec extends AsyncFlatSpec with Matchers { + override val executionContext = scala.scalajs.concurrent.QueueExecutionContext() + implicit val ioRuntime: unsafe.IORuntime = unsafe.IORuntime( + compute = this.executionContext, + blocking = this.executionContext, + config = unsafe.IORuntimeConfig(), + scheduler = unsafe.IORuntime.defaultScheduler, + shutdown = () => (), + ) "Observable" should "recover after mapEffect" in { var recovered = List.empty[Throwable] @@ -76,8 +87,23 @@ class ObservableSpec extends AsyncFlatSpec with Matchers { ), ) - received shouldBe List(15, 10, 6, 3, 1, 0) + cancelable.isEmpty() shouldBe false + received shouldBe List.empty errors shouldBe 0 - cancelable.isEmpty() shouldBe true + + import scala.concurrent.duration._ + + val test = for { + _ <- IO.sleep(FiniteDuration.apply(0, TimeUnit.SECONDS)) + + _ = received shouldBe List(15, 10, 6, 3, 1, 0) + _ = errors shouldBe 0 + + //TODO: why does it need an actual delay? + _ <- IO.sleep(FiniteDuration.apply(10, TimeUnit.MILLISECONDS)) + _ = cancelable.isEmpty() shouldBe true + } yield succeed + + test.unsafeToFuture() } } From 4d6c6c6e5b86f44a537494d4d1a16e877e1065cc Mon Sep 17 00:00:00 2001 From: johannes karoff Date: Sun, 12 Nov 2023 19:51:28 +0100 Subject: [PATCH 3/3] test --- zio/src/test/scala/colibri/ObservableSpec.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zio/src/test/scala/colibri/ObservableSpec.scala b/zio/src/test/scala/colibri/ObservableSpec.scala index d63c3e65..b5155c81 100644 --- a/zio/src/test/scala/colibri/ObservableSpec.scala +++ b/zio/src/test/scala/colibri/ObservableSpec.scala @@ -94,13 +94,11 @@ class ObservableSpec extends AsyncFlatSpec with Matchers { import scala.concurrent.duration._ val test = for { - _ <- IO.sleep(FiniteDuration.apply(0, TimeUnit.SECONDS)) + //TODO: why does it need an actual delay? + _ <- IO.sleep(FiniteDuration.apply(1, TimeUnit.SECONDS)) _ = received shouldBe List(15, 10, 6, 3, 1, 0) _ = errors shouldBe 0 - - //TODO: why does it need an actual delay? - _ <- IO.sleep(FiniteDuration.apply(10, TimeUnit.MILLISECONDS)) _ = cancelable.isEmpty() shouldBe true } yield succeed