Skip to content

Commit 6d2ab01

Browse files
committed
Consolidate tests
1 parent 30123e3 commit 6d2ab01

File tree

4 files changed

+35
-121
lines changed

4 files changed

+35
-121
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.azavea.stac4s.api.client
2+
3+
import com.azavea.stac4s.testing.JsInstances
4+
5+
import sttp.client3.UriContext
6+
7+
class SttpStacClientSpec extends BaseSttpStacClientSpec with JsInstances {
8+
lazy val client = SttpStacClient(backend, uri"http://localhost:9090")
9+
}

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

Lines changed: 0 additions & 111 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.azavea.stac4s.api.client
2+
3+
import com.azavea.stac4s.testing.JvmInstances
4+
5+
import sttp.client3.UriContext
6+
7+
class SttpStacClientSpec extends BaseSttpStacClientSpec with JvmInstances {
8+
lazy val client = SttpStacClient(backend, uri"http://localhost:9090")
9+
}

modules/client/js/src/test/scala/com/azavea/stac4s/api/client/StacClientSpec.scala renamed to modules/client/shared/src/test/scala/com/azavea/stac4s/api/client/BaseSttpStacClientSpec.scala

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
package com.azavea.stac4s.api.client
22

3-
import com.azavea.stac4s.testing.JsInstances
3+
import com.azavea.stac4s.{ItemCollection, StacCollection, StacItem}
44

55
import cats.syntax.either._
66
import eu.timepit.refined.types.all.NonEmptyString
77
import io.circe.JsonObject
88
import io.circe.syntax._
9+
import org.scalacheck.Arbitrary
910
import org.scalatest.BeforeAndAfterAll
1011
import org.scalatest.funspec.AnyFunSpec
1112
import org.scalatest.matchers.should.Matchers
13+
import sttp.client3.Response
1214
import sttp.client3.testing.SttpBackendStub
13-
import sttp.client3.{Response, UriContext}
1415
import sttp.model.Method
1516
import sttp.monad.EitherMonad
1617

17-
class StacClientSpec extends AnyFunSpec with Matchers with JsInstances with BeforeAndAfterAll {
18+
trait BaseSttpStacClientSpec extends AnyFunSpec with Matchers with BeforeAndAfterAll {
19+
20+
def arbCollectionShort: Arbitrary[StacCollection]
21+
def arbItemCollectionShort: Arbitrary[ItemCollection]
22+
def arbItemShort: Arbitrary[StacItem]
23+
24+
def client: BaseSttpStacClient[Either[Throwable, *]]
1825

1926
lazy val backend =
2027
SttpBackendStub(EitherMonad)
@@ -67,41 +74,41 @@ class StacClientSpec extends AnyFunSpec with Matchers with JsInstances with Befo
6774
.asRight
6875
}
6976

70-
describe("StacClientSpec") {
77+
describe("SttpStacClientSpec") {
7178
it("search") {
72-
SttpStacClient(backend, uri"http://localhost:9090").search
79+
client.search
7380
.valueOr(throw _)
7481
.size should be > 0
7582
}
7683

7784
it("collections") {
78-
SttpStacClient(backend, uri"http://localhost:9090").collections
85+
client.collections
7986
.valueOr(throw _)
8087
.size should be > 0
8188
}
8289

8390
it("items") {
84-
SttpStacClient(backend, uri"http://localhost:9090")
91+
client
8592
.items(NonEmptyString.unsafeFrom("collection_id"))
8693
.valueOr(throw _)
8794
.size should be > 0
8895
}
8996

9097
it("item") {
91-
SttpStacClient(backend, uri"http://localhost:9090")
98+
client
9299
.item(NonEmptyString.unsafeFrom("collection_id"), NonEmptyString.unsafeFrom("item_id"))
93100
.valueOr(throw _)
94101
.size should be > 0
95102
}
96103

97104
it("itemCreate") {
98-
SttpStacClient(backend, uri"http://localhost:9090")
105+
client
99106
.itemCreate(NonEmptyString.unsafeFrom("collection_id"), arbItemShort.arbitrary.sample.get)
100107
.map(_.id should not be empty)
101108
}
102109

103110
it("collectionCreate") {
104-
SttpStacClient(backend, uri"http://localhost:9090")
111+
client
105112
.collectionCreate(arbCollectionShort.arbitrary.sample.get)
106113
.map(_.id should not be empty)
107114
}

0 commit comments

Comments
 (0)