mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Some clean-up in criteria
package
This commit is contained in:
parent
12b4a48842
commit
bbd3882a75
4 changed files with 14 additions and 16 deletions
|
@ -10,8 +10,9 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("Operators", func() {
|
||||
rangeStart := Time(time.Date(2021, 10, 01, 0, 0, 0, 0, time.Local))
|
||||
rangeEnd := Time(time.Date(2021, 11, 01, 0, 0, 0, 0, time.Local))
|
||||
rangeStart := date(time.Date(2021, 10, 01, 0, 0, 0, 0, time.Local))
|
||||
rangeEnd := date(time.Date(2021, 11, 01, 0, 0, 0, 0, time.Local))
|
||||
|
||||
DescribeTable("ToSQL",
|
||||
func(op Expression, expectedSql string, expectedArgs ...any) {
|
||||
sql, args, err := op.ToSql()
|
||||
|
@ -29,7 +30,7 @@ var _ = Describe("Operators", func() {
|
|||
Entry("startsWith", StartsWith{"title": "Low Rider"}, "media_file.title LIKE ?", "Low Rider%"),
|
||||
Entry("endsWith", EndsWith{"title": "Low Rider"}, "media_file.title LIKE ?", "%Low Rider"),
|
||||
Entry("inTheRange [number]", InTheRange{"year": []int{1980, 1990}}, "(media_file.year >= ? AND media_file.year <= ?)", 1980, 1990),
|
||||
Entry("inTheRange [date]", InTheRange{"lastPlayed": []Time{rangeStart, rangeEnd}}, "(annotation.play_date >= ? AND annotation.play_date <= ?)", rangeStart, rangeEnd),
|
||||
Entry("inTheRange [date]", InTheRange{"lastPlayed": []date{rangeStart, rangeEnd}}, "(annotation.play_date >= ? AND annotation.play_date <= ?)", rangeStart, rangeEnd),
|
||||
Entry("before", Before{"lastPlayed": rangeStart}, "annotation.play_date < ?", rangeStart),
|
||||
Entry("after", After{"lastPlayed": rangeStart}, "annotation.play_date > ?", rangeStart),
|
||||
// TODO These may be flaky
|
||||
|
@ -37,7 +38,7 @@ var _ = Describe("Operators", func() {
|
|||
Entry("notInTheLast", NotInTheLast{"lastPlayed": 30}, "(annotation.play_date < ? OR annotation.play_date IS NULL)", startOfPeriod(30, time.Now())),
|
||||
)
|
||||
|
||||
DescribeTable("JSON Conversion",
|
||||
DescribeTable("JSON Marshaling",
|
||||
func(op Expression, jsonString string) {
|
||||
obj := And{op}
|
||||
newJs, err := json.Marshal(obj)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue