mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Move to munit in query module
This commit is contained in:
@ -156,7 +156,6 @@ object ItemQueryGenerator {
|
||||
date match {
|
||||
case d: Date.DateLiteral =>
|
||||
val ld = dateLiteralToDate(today)(d)
|
||||
println(s">>>> date= $ld")
|
||||
Timestamp.atUtc(ld.atStartOfDay)
|
||||
case Date.Calc(date, c, period) =>
|
||||
val ld = c match {
|
||||
@ -165,7 +164,6 @@ object ItemQueryGenerator {
|
||||
case Date.CalcDirection.Minus =>
|
||||
dateLiteralToDate(today)(date).minus(period)
|
||||
}
|
||||
println(s">>>> date= $ld")
|
||||
Timestamp.atUtc(ld.atStartOfDay())
|
||||
}
|
||||
|
||||
|
@ -24,14 +24,17 @@ object ItemQueryGeneratorTest extends SimpleTestSuite {
|
||||
)
|
||||
val now: LocalDate = LocalDate.of(2021, 2, 25)
|
||||
|
||||
def mkTimestamp(year: Int, month: Int, day: Int): Timestamp =
|
||||
Timestamp.atUtc(LocalDate.of(year, month, day).atStartOfDay())
|
||||
|
||||
test("basic test") {
|
||||
val q = ItemQueryParser
|
||||
.parseUnsafe("(& name:hello date>=2020-02-01 (| source=expense folder=test ))")
|
||||
.parseUnsafe("(& name:hello date>=2020-02-01 (| source:expense* folder=test ))")
|
||||
val cond = ItemQueryGenerator(now, tables, Ident.unsafe("coll"))(q)
|
||||
val expect =
|
||||
tables.item.name.like("hello") && tables.item.itemDate >= Timestamp.atUtc(
|
||||
LocalDate.of(2020, 2, 1).atStartOfDay()
|
||||
) && (tables.item.source === "expense" || tables.folder.name === "test")
|
||||
tables.item.name.like("hello") &&
|
||||
tables.item.itemDate >= mkTimestamp(2020, 2, 1) &&
|
||||
(tables.item.source.like("expense%") || tables.folder.name === "test")
|
||||
|
||||
assertEquals(cond, expect)
|
||||
}
|
||||
|
Reference in New Issue
Block a user