Skip to content

Commit

Permalink
fix incorrect deprecation fix on Dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-klass committed Jan 22, 2025
1 parent 392556c commit 5ce6acd
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sttp.tapir.client.tests.ClientTests
import sttp.tapir.{DecodeResult, Endpoint}

abstract class SttpClientTests[R >: WebSockets with Fs2Streams[IO]] extends ClientTests[R] {
val (dispatcher, closeDispatcher) = Dispatcher[IO].allocated.unsafeRunSync()
val (dispatcher, closeDispatcher) = Dispatcher.parallel[IO].allocated.unsafeRunSync()
val backend: SttpBackend[IO, R] = HttpClientFs2Backend[IO](dispatcher).unsafeRunSync()
def wsToPipe: WebSocketToPipe[R]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}

class NettyCatsCreateServerStubTest extends CreateServerStubTest[IO, NettyCatsServerOptions[IO]] {
val (dispatcher, shutdownDispatcher) = Dispatcher[IO].allocated.unsafeRunSync()
val (dispatcher, shutdownDispatcher) = Dispatcher.parallel[IO].allocated.unsafeRunSync()

override def customiseInterceptors: CustomiseInterceptors[IO, NettyCatsServerOptions[IO]] =
NettyCatsServerOptions.customiseInterceptors[IO](dispatcher)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ class ServerCancellationTests[F[_], OPTIONS, ROUTE](createServerTest: CreateServ
val resp: IO[_] = basicRequest.get(uri"$baseUri").readTimeout(300.millis).send(backend)

resp
.map { case result =>
fail(s"Expected cancellation, but received a result: $result")
}
.map(result => fail(s"Expected cancellation, but received a result: $result"))
.handleErrorWith {
case _: SttpClientException.TimeoutException => // expected, this is how we trigged client-side cancellation
IO(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait TestServerInterpreter[F[_], +R, OPTIONS, ROUTE] {
): Resource[IO, (Port, KillSwitch)] = for {
stopSignal <- Resource.eval(Deferred[IO, Unit])
portValue <- Resource.eval(Deferred[IO, Port])
_ <- server(routes, gracefulShutdownTimeout).evalTap(portValue.complete).use(_ => stopSignal.get).background
_ <- server(routes, gracefulShutdownTimeout).evalTap(portValue.complete).surround(stopSignal.get).background
port <- Resource.eval(portValue.get)
} yield (port, stopSignal.complete(()).void)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import sttp.tapir.server.tests.{CreateServerStubTest, ServerStubStreamingTest, S
import scala.concurrent.Future

class VertxCatsCreateServerStubTest extends CreateServerStubTest[IO, VertxCatsServerOptions[IO]] {
private val (dispatcher, shutdownDispatcher) = Dispatcher.sequential[IO].allocated.unsafeRunSync()
private val (dispatcher, shutdownDispatcher) = Dispatcher.parallel[IO].allocated.unsafeRunSync()

override def customiseInterceptors: CustomiseInterceptors[IO, VertxCatsServerOptions[IO]] =
VertxCatsServerOptions.customiseInterceptors(dispatcher)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import scala.concurrent.duration._

class Fs2StreamTest extends AsyncFlatSpec with Matchers with BeforeAndAfterAll {

private val (dispatcher, shutdownDispatcher) = Dispatcher.sequential[IO].allocated.unsafeRunSync()
private val (dispatcher, shutdownDispatcher) = Dispatcher.parallel[IO].allocated.unsafeRunSync()

override protected def afterAll(): Unit = {
shutdownDispatcher.unsafeRunSync()
Expand Down
2 changes: 1 addition & 1 deletion tests/src/main/scalajvm/sttp/tapir/tests/TestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait TestSuite extends AsyncFunSuite with BeforeAndAfterAll {
def tests: Resource[IO, List[Test]]
def testNameFilter: Option[String] = None // define to run a single test (temporarily for debugging)

protected val (dispatcher, shutdownDispatcher) = Dispatcher.sequential[IO].allocated.unsafeRunSync()
protected val (dispatcher, shutdownDispatcher) = Dispatcher.parallel[IO].allocated.unsafeRunSync()

// we need to register the tests when the class is constructed, as otherwise scalatest skips it
val (allTests, doRelease) = tests.allocated.unsafeRunSync()
Expand Down

0 comments on commit 5ce6acd

Please sign in to comment.