Skip to content

Commit

Permalink
Merge pull request #160 from senia-psm/zio_2.0.0
Browse files Browse the repository at this point in the history
zio 2.0.0
  • Loading branch information
senia-psm authored Jun 24, 2022
2 parents 43f3104 + f483048 commit 5f36797
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ThisBuild / publishTo := sonatypePublishToBundle.value
addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")

lazy val zioVersion = "2.0.0-RC6"
lazy val zioVersion = "2.0.0"
lazy val akkaVersion = "2.6.19"
lazy val akkaHttpVersion = "10.2.9"

Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/zio/test/akkahttp/AkkaZIOSpecDefault.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package zio.test.akkahttp

import zio._
import zio.test.{Spec, TestEnvironment, ZIOSpec}
import zio.test.{testEnvironment, Spec, TestEnvironment, ZIOSpec}

trait AkkaZIOSpecDefault extends ZIOSpec[RouteTestEnvironment.TestEnvironment with TestEnvironment] with RouteTest {

override val bootstrap
: ZLayer[ZIOAppArgs with Scope, Any, RouteTestEnvironment.TestEnvironment with TestEnvironment] =
zio.ZEnv.live >>> TestEnvironment.live >+> RouteTestEnvironment.environment
override val bootstrap: ZLayer[Scope, Any, RouteTestEnvironment.TestEnvironment with TestEnvironment] =
testEnvironment >+> RouteTestEnvironment.environment

def spec: Spec[RouteTestEnvironment.TestEnvironment with TestEnvironment with Scope, Any]
}
9 changes: 7 additions & 2 deletions src/main/scala/zio/test/akkahttp/RouteTestResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import akka.http.scaladsl.server.Rejection
import akka.http.scaladsl.unmarshalling.{FromEntityUnmarshaller, FromResponseUnmarshaller, Unmarshal}
import akka.stream.Materializer
import akka.stream.scaladsl.{Sink, Source}
import zio.Unsafe.unsafeCompat
import zio._
import zio.test.akkahttp.RouteTest.Environment
import zio.test.akkahttp.RouteTestResult.Completed
Expand Down Expand Up @@ -159,11 +160,15 @@ object RouteTestResult {

def entityAs[T : FromEntityUnmarshaller : ClassTag]: Either[Throwable, T] =
// The entry is already in memory. Run here is not so bad.
runtime.unsafeRun(ZIO.fromFuture(implicit ec => Unmarshal(entity).to[T]).either)
unsafeCompat { implicit u =>
runtime.unsafe.run(ZIO.fromFuture(implicit ec => Unmarshal(entity).to[T]).either).getOrThrow()
}

def responseAs[T : FromResponseUnmarshaller : ClassTag]: Either[Throwable, T] =
// The response is already in memory. Run here is not so bad.
runtime.unsafeRun(ZIO.fromFuture(implicit ec => Unmarshal(response).to[T]).either)
unsafeCompat { implicit u =>
runtime.unsafe.run(ZIO.fromFuture(implicit ec => Unmarshal(response).to[T]).either).getOrThrow()
}

def contentType: ContentType = entity.contentType

Expand Down

0 comments on commit 5f36797

Please sign in to comment.