Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonaNedeljkovic committed Jun 24, 2023
1 parent 62b3312 commit b901e6d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,41 @@ object HttpExecutorSpec extends IntegrationSpec {
}
} @@ after(Executor.execute(ElasticRequest.deleteIndex(geoDistanceIndex)).orDie)
),
suite("geo-polygon query")(
test("using geo-polygon query") {
checkOnce(genTestDocument) { document =>
val indexDefinition =
"""
|{
| "mappings": {
| "properties": {
| "locationField": {
| "type": "geo_point"
| }
| }
| }
|}
|""".stripMargin

for {
_ <- Executor.execute(ElasticRequest.createIndex(geoPolygonIndex, indexDefinition))
_ <- Executor.execute(ElasticRequest.deleteByQuery(geoPolygonIndex, matchAll))
_ <- Executor.execute(
ElasticRequest.create[TestDocument](geoPolygonIndex, document).refreshTrue
)
r1 <- Executor
.execute(
ElasticRequest.search(
geoPolygonIndex,
ElasticQuery
.geoPolygon("locationField", List("0, 0", "0, 90", "90, 90", "90, 0"))
)
)
.documentAs[TestDocument]
} yield assertTrue(r1 == Chunk(document))
}
} @@ after(Executor.execute(ElasticRequest.deleteIndex(geoPolygonIndex)).orDie)
),
suite("search for documents using FunctionScore query")(
test("using randomScore function") {
checkOnce(genTestDocument, genTestDocument) { (firstDocument, secondDocument) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ trait IntegrationSpec extends ZIOSpecDefault {

val geoDistanceIndex: IndexName = IndexName("geo-distance-index")

val geoPolygonIndex: IndexName = IndexName("geo-polygon-index")

val prepareElasticsearchIndexForTests: TestAspect[Nothing, Any, Throwable, Any] = beforeAll((for {
_ <- Executor.execute(ElasticRequest.createIndex(index))
_ <- Executor.execute(ElasticRequest.deleteByQuery(index, matchAll).refreshTrue)
Expand Down

0 comments on commit b901e6d

Please sign in to comment.