mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 02:48:26 +00:00
Move to munit in query module
This commit is contained in:
@ -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