Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eikek committed Feb 27, 2024
1 parent 90c7d52 commit fa1bc5a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ class SearchApiSpec extends CatsEffectSuite with SearchSolrSpec:
results <- searchApi
.query(mkQuery("matching"))
.map(_.fold(err => fail(s"Calling Search API failed with $err"), identity))
} yield assert(results.items contains toApiProject(project1))
} yield assert(results.items.map(scoreToNone) contains toApiProject(project1))
}

private def scoreToNone(e: SearchEntity): SearchEntity = e match
case p: Project => p.copy(score = None)

private def mkQuery(phrase: String): QueryInput =
QueryInput.pageOne(Query.parse(phrase).fold(sys.error, identity))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class SearchProvisionerSpec extends CatsEffectSuite with QueueSpec with SearchSo
.awakeEvery[IO](500 millis)
.evalMap(_ => solrClient.findProjects("*"))
.flatMap(Stream.emits(_))
.evalMap(d => solrDocs.update(_ + d))
.evalMap(d => solrDocs.update(_ + d.copy(score = None)))
.compile
.drain
.start
Expand Down Expand Up @@ -103,7 +103,7 @@ class SearchProvisionerSpec extends CatsEffectSuite with QueueSpec with SearchSo
.evalMap(_ => solrClient.findProjects("*"))
.flatMap(Stream.emits(_))
.evalTap(IO.println)
.evalMap(d => solrDocs.update(_ + d))
.evalMap(d => solrDocs.update(_ + d.copy(score = None)))
.compile
.drain
.start
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
/*
* Copyright 2024 Swiss Data Science Center (SDSC)
* A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
* Eidgenössische Technische Hochschule Zürich (ETHZ).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package io.renku.search.solr.client
import cats.effect.IO
import io.renku.search.solr.client.SearchSolrClientGenerators.*
import munit.CatsEffectSuite
import io.renku.search.query.Query

class SearchSolrClientSpec extends CatsEffectSuite with SearchSolrSpec:

Expand All @@ -30,7 +31,8 @@ class SearchSolrClientSpec extends CatsEffectSuite with SearchSolrSpec:
projectDocumentGen("solr-project", "solr project description").generateOne
for {
_ <- client.insertProjects(Seq(project))
r <- client.findProjects("solr")
_ = assert(r contains project)
r <- client.queryProjects(Query.parse("solr").toOption.get, 10,0)
_ <- IO.println(r.responseBody.docs)
_ = assert(r.responseBody.docs.map(_.copy(score = None)) contains project)
} yield ()
}

0 comments on commit fa1bc5a

Please sign in to comment.