Skip to content

Commit

Permalink
Fs2 connection test (#2176)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pask423 committed May 10, 2024
1 parent 16c5f07 commit e1f4aa0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
Expand Up @@ -8,7 +8,4 @@ import sttp.client4.impl.cats.{CatsTestBase, TestIODispatcher}
class AsyncHttpClientFs2HttpTest extends AsyncHttpClientHttpTest[IO] with TestIODispatcher with CatsTestBase {
override val backend: Backend[IO] =
AsyncHttpClientFs2Backend[IO](dispatcher = dispatcher).unsafeRunSync()

// for some unknown reason this single test fails using the fs2 implementation
override def supportsConnectionRefusedTest = false
}
27 changes: 12 additions & 15 deletions core/src/test/scala/sttp/client4/testing/HttpTest.scala
Expand Up @@ -47,7 +47,6 @@ trait HttpTest[F[_]]

protected def supportsRequestTimeout = true
protected def supportsSttpExceptions = true
protected def supportsConnectionRefusedTest = true
protected def supportsMultipart = true
protected def supportsCustomMultipartContentType = true
protected def supportsCustomMultipartEncoding = true
Expand Down Expand Up @@ -640,21 +639,19 @@ trait HttpTest[F[_]]
}
}

if (supportsConnectionRefusedTest) {
"connection exceptions - connection refused" in {
val req = basicRequest
.get(uri"http://localhost:7918")
.response(asString)
"connection exceptions - connection refused" in {
val req = basicRequest
.get(uri"http://localhost:7918")
.response(asString)

Future(req.send(backend)).flatMap(_.toFuture()).failed.map { e =>
info("Sending request failed", Some(e))
try e shouldBe a[SttpClientException.ConnectException]
catch {
case t: Throwable =>
info("Not a connect exception, printing stack trace")
e.printStackTrace()
throw t
}
Future(req.send(backend)).flatMap(_.toFuture()).failed.map { e =>
info("Sending request failed", Some(e))
try e shouldBe a[SttpClientException.ConnectException]
catch {
case t: Throwable =>
info("Not a connect exception, printing stack trace")
e.printStackTrace()
throw t
}
}
}
Expand Down

0 comments on commit e1f4aa0

Please sign in to comment.