mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Move to munit in query module
This commit is contained in:
@ -2,9 +2,9 @@ package docspell.query.internal
|
||||
|
||||
import docspell.query.ItemQuery.Attr
|
||||
import docspell.query.internal.AttrParser
|
||||
import minitest._
|
||||
import munit._
|
||||
|
||||
object AttrParserTest extends SimpleTestSuite {
|
||||
class AttrParserTest extends FunSuite {
|
||||
|
||||
test("string attributes") {
|
||||
val p = AttrParser.stringAttr
|
||||
|
@ -1,10 +1,10 @@
|
||||
package docspell.query.internal
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import cats.data.{NonEmptyList => Nel}
|
||||
import docspell.query.internal.BasicParser
|
||||
|
||||
object BasicParserTest extends SimpleTestSuite {
|
||||
class BasicParserTest extends FunSuite {
|
||||
test("single string values") {
|
||||
val p = BasicParser.singleString
|
||||
assertEquals(p.parseAll("abcde"), Right("abcde"))
|
||||
|
@ -1,19 +1,10 @@
|
||||
package docspell.query.internal
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import docspell.query.Date
|
||||
import java.time.Period
|
||||
|
||||
object DateParserTest extends SimpleTestSuite {
|
||||
|
||||
def ld(year: Int, m: Int, d: Int): Date.DateLiteral =
|
||||
Date(year, m, d).fold(throw _, identity)
|
||||
|
||||
def ldPlus(year: Int, m: Int, d: Int, p: Period): Date.Calc =
|
||||
Date.Calc(ld(year, m, d), Date.CalcDirection.Plus, p)
|
||||
|
||||
def ldMinus(year: Int, m: Int, d: Int, p: Period): Date.Calc =
|
||||
Date.Calc(ld(year, m, d), Date.CalcDirection.Minus, p)
|
||||
class DateParserTest extends FunSuite with ValueHelper {
|
||||
|
||||
test("local date string") {
|
||||
val p = DateParser.dateFromString
|
||||
|
@ -1,11 +1,10 @@
|
||||
package docspell.query.internal
|
||||
|
||||
import docspell.query.ItemQuery._
|
||||
import docspell.query.internal.SimpleExprParserTest.stringExpr
|
||||
import minitest._
|
||||
import munit._
|
||||
import cats.data.{NonEmptyList => Nel}
|
||||
|
||||
object ExprParserTest extends SimpleTestSuite {
|
||||
class ExprParserTest extends FunSuite with ValueHelper {
|
||||
|
||||
test("simple expr") {
|
||||
val p = ExprParser.exprParser
|
||||
|
@ -1,10 +1,10 @@
|
||||
package docspell.query.internal
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import docspell.query.ItemQueryParser
|
||||
import docspell.query.ItemQuery
|
||||
|
||||
object ItemQueryParserTest extends SimpleTestSuite {
|
||||
class ItemQueryParserTest extends FunSuite {
|
||||
|
||||
test("reduce ands") {
|
||||
val q = ItemQueryParser.parseUnsafe("(&(&(&(& name:hello))))")
|
||||
|
@ -1,9 +1,9 @@
|
||||
package docspell.query.internal
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import cats.parse.{Parser => P}
|
||||
|
||||
object MacroParserTest extends SimpleTestSuite {
|
||||
class MacroParserTest extends FunSuite {
|
||||
|
||||
test("fail with unkown macro names") {
|
||||
val p = MacroParser.parser(Map.empty)
|
||||
|
@ -1,10 +1,10 @@
|
||||
package docspell.query.internal
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import docspell.query.ItemQuery.{Operator, TagOperator}
|
||||
import docspell.query.internal.OperatorParser
|
||||
|
||||
object OperatorParserTest extends SimpleTestSuite {
|
||||
class OperatorParserTest extends FunSuite {
|
||||
test("operator values") {
|
||||
val p = OperatorParser.op
|
||||
assertEquals(p.parseAll("="), Right(Operator.Eq))
|
||||
|
@ -2,11 +2,11 @@ package docspell.query.internal
|
||||
|
||||
import cats.data.{NonEmptyList => Nel}
|
||||
import docspell.query.ItemQuery._
|
||||
import minitest._
|
||||
import munit._
|
||||
import docspell.query.Date
|
||||
import java.time.Period
|
||||
|
||||
object SimpleExprParserTest extends SimpleTestSuite {
|
||||
class SimpleExprParserTest extends FunSuite with ValueHelper {
|
||||
|
||||
test("string expr") {
|
||||
val p = SimpleExprParser.stringExpr
|
||||
@ -175,12 +175,4 @@ object SimpleExprParserTest extends SimpleTestSuite {
|
||||
)
|
||||
}
|
||||
|
||||
def ld(y: Int, m: Int, d: Int) =
|
||||
DateParserTest.ld(y, m, d)
|
||||
|
||||
def stringExpr(op: Operator, name: Attr.StringAttr, value: String): Expr.SimpleExpr =
|
||||
Expr.SimpleExpr(op, Property.StringProperty(name, value))
|
||||
|
||||
def dateExpr(op: Operator, name: Attr.DateAttr, value: Date): Expr.SimpleExpr =
|
||||
Expr.SimpleExpr(op, Property.DateProperty(name, value))
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package docspell.query.internal
|
||||
|
||||
import docspell.query.Date
|
||||
import docspell.query.ItemQuery._
|
||||
import java.time.Period
|
||||
|
||||
trait ValueHelper {
|
||||
|
||||
def ld(year: Int, m: Int, d: Int): Date.DateLiteral =
|
||||
Date(year, m, d).fold(throw _, identity)
|
||||
|
||||
def ldPlus(year: Int, m: Int, d: Int, p: Period): Date.Calc =
|
||||
Date.Calc(ld(year, m, d), Date.CalcDirection.Plus, p)
|
||||
|
||||
def ldMinus(year: Int, m: Int, d: Int, p: Period): Date.Calc =
|
||||
Date.Calc(ld(year, m, d), Date.CalcDirection.Minus, p)
|
||||
|
||||
def stringExpr(op: Operator, name: Attr.StringAttr, value: String): Expr.SimpleExpr =
|
||||
Expr.SimpleExpr(op, Property.StringProperty(name, value))
|
||||
|
||||
def dateExpr(op: Operator, name: Attr.DateAttr, value: Date): Expr.SimpleExpr =
|
||||
Expr.SimpleExpr(op, Property.DateProperty(name, value))
|
||||
|
||||
}
|
Reference in New Issue
Block a user