Skip to content

Commit

Permalink
Test on a dynamic query with non-constant value
Browse files Browse the repository at this point in the history
  • Loading branch information
danslapman committed Jan 18, 2025
1 parent cd38bb7 commit 4be60d9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions oolong-mongo/src/test/scala/oolong/mongo/QuerySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,25 @@ class QuerySpec extends AnyFunSuite {
)
}

test("Conditional query with Pattern does not require lifting spec") {
case class NameTest(name: String)

val nOp = Option("some_name")
val q = nOp.map { n =>
query[NameTest](nt => Pattern.compile(n, Pattern.CASE_INSENSITIVE).matcher(nt.name).matches())
}
val repr = renderQuery[NameTest](_.name == "some_name")

test(
q.getOrElse(BsonDocument()),
repr,
BsonDocument(
"name" -> BsonDocument("$regex" -> BsonString("some_name"), "$options" -> BsonString("i"))
),
ignoreRender = true
)
}

private inline def test(
query: BsonDocument,
repr: String,
Expand Down

0 comments on commit 4be60d9

Please sign in to comment.