Skip to content

Commit

Permalink
Revert upgrade of wiremock due to bug in 3.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seakayone committed Dec 19, 2024
1 parent 96d6daf commit f33c63b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 3 additions & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ object Dependencies {
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.19"

val testcontainers = "org.testcontainers" % "testcontainers" % "1.20.4"
val wiremock = "org.wiremock" % "wiremock" % "3.10.0"

// use version 3.9.2 until https://github.com/wiremock/wiremock/issues/2911 is fixed
val wiremock = "org.wiremock" % "wiremock" % "3.9.2"

// found/added by the plugin but deleted anyway
val commonsLang3 = "org.apache.commons" % "commons-lang3" % "3.17.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,12 @@ object HttpMockServer {
val random: ULayer[TestPort] = ZLayer.fromZIO(Random.nextIntBetween(1000, 10_000).map(TestPort.apply))
}

private def acquireWireMockServer: ZIO[TestPort, Throwable, WireMockServer] =
ZIO.serviceWith[TestPort](_.value).flatMap { port =>
val layer: ZLayer[Scope & TestPort, Throwable, WireMockServer] =
ZLayer.fromZIO(ZIO.acquireRelease(ZIO.serviceWithZIO[TestPort] { port =>
ZIO.attempt {
val server = new WireMockServer(options().port(port)); // No-args constructor will start on port 8080, no HTTPS
val server = new WireMockServer(options().port(port.value))
server.start()
server
}
}

private def releaseWireMockServer(server: WireMockServer) = ZIO.attempt(server.stop()).logError.ignore

val layer: ZLayer[Scope & TestPort, Throwable, WireMockServer] =
ZLayer.fromZIO(ZIO.acquireRelease(acquireWireMockServer)(releaseWireMockServer))
})(server => ZIO.attempt(server.stop()).logError.orDie))
}

0 comments on commit f33c63b

Please sign in to comment.