Skip to content

Commit

Permalink
Use Latest ZIO Snapshot (#2345)
Browse files Browse the repository at this point in the history
* use latest zio snapshot

* update

* cleanup
  • Loading branch information
adamgfraser authored Jul 29, 2023
1 parent f36a8ca commit 1b09b78
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Dependencies {
val NettyVersion = "4.1.94.Final"
val NettyIncubatorVersion = "0.0.20.Final"
val ScalaCompactCollectionVersion = "2.11.0"
val ZioVersion = "2.0.13"
val ZioVersion = "2.0.15+81-32928b56-SNAPSHOT"
val ZioCliVersion = "0.5.0"
val ZioSchemaVersion = "0.4.13"
val SttpVersion = "3.3.18"
Expand Down
36 changes: 1 addition & 35 deletions zio-http/src/test/scala/zio/http/WebSocketSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,6 @@ import zio.http.ChannelEvent.{Read, Unregistered, UserEvent, UserEventTriggered}
import zio.http.internal.{DynamicServer, HttpRunnableSpec, severTestLayer}

object WebSocketSpec extends HttpRunnableSpec {
implicit class scopeDisconnect(scope: zio.Scope) {
def disconnect(label: String): Scope =
new Scope {
def addFinalizerExit(finalizer: Exit[Any, Any] => UIO[Any])(implicit trace: zio.Trace): UIO[Unit] =
scope.addFinalizerExit { (exit: Exit[Any, Any]) =>
val warn =
ZIO
.logWarning(
s"A finalizer for layer ${label} has taken more than 1 minute to complete. Skipping this finalizer and moving onto the next one.",
)
.delay(1.minute)
.unit

finalizer(exit).disconnect.race(warn)
}

def forkWith(executionStrategy: => zio.ExecutionStrategy)(implicit trace: zio.Trace): UIO[Scope.Closeable] =
scope.forkWith(executionStrategy)
}
}
implicit class layerDisconnect[I, E, O](layer: ZLayer[I, E, O]) {
def disconnect(label: String): ZLayer[I, E, O] =
ZLayer.scopedEnvironment[I] {
for {
scope <- ZIO.scope
zenv <- layer.build(scope.disconnect(label))
} yield zenv
}
}

private val websocketSpec = suite("WebsocketSpec")(
test("channel events between client and server") {
Expand Down Expand Up @@ -241,12 +212,7 @@ object WebSocketSpec extends HttpRunnableSpec {
serve.as(List(websocketSpec))
}
}
.provideShared(
DynamicServer.live.disconnect("DynamicServer.live"),
severTestLayer.disconnect("serverTestLayer"),
Client.default.disconnect("Client.default"),
Scope.default,
) @@
.provideShared(DynamicServer.live, severTestLayer, Client.default, Scope.default) @@
timeout(30 seconds) @@ diagnose(30.seconds) @@ withLiveClock @@ sequential

final class MessageCollector[A](ref: Ref[List[A]], promise: Promise[Nothing, Unit]) {
Expand Down

0 comments on commit 1b09b78

Please sign in to comment.