|
|
|
|
@ -248,6 +248,25 @@ struct SmartPlaylistTests { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Verifies that lessThan on an integer field returns only tracks strictly |
|
|
|
|
// below the threshold value. |
|
|
|
|
@Test func fetchTracksWithLessThanCondition() throws { |
|
|
|
|
// Step 1: Insert tracks with years 1990, 2010, 2020 |
|
|
|
|
// Step 2: Fetch with year < 2000 |
|
|
|
|
// Step 3: Verify only the 1990 track is returned |
|
|
|
|
let db = try DatabaseService(inMemory: true) |
|
|
|
|
var t1 = Track.fixture(fileURL: "/a.mp3", year: 1990) |
|
|
|
|
var t2 = Track.fixture(fileURL: "/b.mp3", year: 2010) |
|
|
|
|
var t3 = Track.fixture(fileURL: "/c.mp3", year: 2020) |
|
|
|
|
try db.insert(&t1) |
|
|
|
|
try db.insert(&t2) |
|
|
|
|
try db.insert(&t3) |
|
|
|
|
let conditions = [SmartPlaylistCondition(field: .year, op: .lessThan, value: .int(2000))] |
|
|
|
|
let results = try db.fetchTracks(conditions: conditions, sortColumn: "title", ascending: true) |
|
|
|
|
#expect(results.count == 1) |
|
|
|
|
#expect((results[0].year ?? 0) < 2000) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Updates the conditions of a structured smart playlist and verifies the updated |
|
|
|
|
// conditions are persisted and fetch back correctly. |
|
|
|
|
@Test func updateSmartPlaylistConditionsPersists() throws { |
|
|
|
|
|