Skip to content

Commit f483fe2

Browse files
committed
Close sttp client in tests
1 parent 46d9c57 commit f483fe2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

modules/client/js/src/test/scala/com/azavea/stac4s/api/client/StacClientSpec.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package com.azavea.stac4s.api.client
22

33
import com.azavea.stac4s.testing.JsInstances
4-
54
import cats.syntax.either._
65
import eu.timepit.refined.types.all.NonEmptyString
76
import io.circe.JsonObject
87
import io.circe.syntax._
8+
import org.scalatest.BeforeAndAfterAll
99
import org.scalatest.funspec.AnyFunSpec
1010
import org.scalatest.matchers.should.Matchers
1111
import sttp.client3.testing.SttpBackendStub
1212
import sttp.client3.{Response, UriContext}
1313
import sttp.monad.EitherMonad
1414

15-
class StacClientSpec extends AnyFunSpec with Matchers with JsInstances {
15+
class StacClientSpec extends AnyFunSpec with Matchers with JsInstances with BeforeAndAfterAll {
1616

1717
lazy val backend =
1818
SttpBackendStub(EitherMonad)
@@ -69,4 +69,6 @@ class StacClientSpec extends AnyFunSpec with Matchers with JsInstances {
6969
.size should be > 0
7070
}
7171
}
72+
73+
override def afterAll(): Unit = backend.close().valueOr(throw _)
7274
}

modules/client/jvm/src/test/scala/com/azavea/stac4s/api/client/StacClientSpec.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.azavea.stac4s.api.client
22

33
import com.azavea.stac4s.testing.JvmInstances
4-
54
import cats.effect.{Blocker, IO}
65
import cats.syntax.applicative._
76
import cats.syntax.either._
@@ -10,15 +9,16 @@ import eu.timepit.refined.collection.Empty
109
import eu.timepit.refined.types.all.NonEmptyString
1110
import io.circe.JsonObject
1211
import io.circe.syntax._
12+
import org.scalatest.BeforeAndAfterAll
1313
import sttp.client3.asynchttpclient.cats.AsyncHttpClientCatsBackend
1414
import sttp.client3.http4s.Http4sBackend
1515
import sttp.client3.impl.cats.CatsMonadAsyncError
1616
import sttp.client3.testing.SttpBackendStub
1717
import sttp.client3.{Response, UriContext}
1818

19-
class StacClientSpec extends IOSpec with JvmInstances {
19+
class StacClientSpec extends IOSpec with JvmInstances with BeforeAndAfterAll {
2020

21-
lazy val backend: SttpBackendStub[IO, Nothing] =
21+
lazy val backend =
2222
SttpBackendStub(new CatsMonadAsyncError[IO]())
2323
.whenRequestMatches(_.uri.path == Seq("search"))
2424
.thenRespondF { _ =>
@@ -88,4 +88,6 @@ class StacClientSpec extends IOSpec with JvmInstances {
8888
res map (_ shouldNot be(Empty))
8989
}
9090
}
91+
92+
override def afterAll(): Unit = backend.close().unsafeRunSync()
9193
}

0 commit comments

Comments
 (0)