|
|
|
|
@ -264,6 +264,26 @@ struct DatabaseServiceTests { |
|
|
|
|
#expect(total == 0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Inserts 5 tracks, fetches 3 by ID, verifies only those 3 are returned |
|
|
|
|
// in the order of the requested IDs. |
|
|
|
|
@Test func fetchTracksByIds() throws { |
|
|
|
|
let db = try DatabaseService(inMemory: true) |
|
|
|
|
var tracks = (0..<5).map { i in |
|
|
|
|
Track.fixture(fileURL: "/track\(i).mp3", title: "Track \(i)") |
|
|
|
|
} |
|
|
|
|
for i in tracks.indices { |
|
|
|
|
try db.insert(&tracks[i]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let ids: [Int64] = [tracks[2].id!, tracks[0].id!, tracks[4].id!] |
|
|
|
|
let result = try db.fetchTracksByIds(ids) |
|
|
|
|
|
|
|
|
|
#expect(result.count == 3) |
|
|
|
|
#expect(result[0].id == tracks[2].id) |
|
|
|
|
#expect(result[1].id == tracks[0].id) |
|
|
|
|
#expect(result[2].id == tracks[4].id) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Inserts tracks in different months and verifies fetchMonthlyAdditions returns |
|
|
|
|
// the correct per-month counts covering the requested range including empty months. |
|
|
|
|
// Uses a UTC calendar to match the implementation, which uses UTC month boundaries |
|
|
|
|
|