Implement remote library metadata sync for iPhone
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
import Foundation
|
||||
import XCTest
|
||||
import VelodyDomain
|
||||
@testable import VelodyPersistence
|
||||
|
||||
final class RemoteLibraryStoreTests: XCTestCase {
|
||||
func testFileRemoteLibraryStorePersistsTracksAcrossInstances() async throws {
|
||||
let fileManager = FileManager.default
|
||||
let tempDirectory = fileManager.temporaryDirectory.appendingPathComponent(
|
||||
UUID().uuidString,
|
||||
isDirectory: true
|
||||
)
|
||||
let fileURL = tempDirectory.appendingPathComponent("remote-library.json")
|
||||
|
||||
defer {
|
||||
try? fileManager.removeItem(at: tempDirectory)
|
||||
}
|
||||
|
||||
let firstStore = try FileRemoteLibraryStore(fileURL: fileURL)
|
||||
let tracks = [
|
||||
RemoteTrack(
|
||||
trackId: "track-123",
|
||||
title: "Remote Title",
|
||||
artist: "Remote Artist",
|
||||
durationSeconds: 245,
|
||||
sha256: String(repeating: "a", count: 64),
|
||||
assetId: "asset-456",
|
||||
createdAt: "2026-05-29T08:00:00.000Z",
|
||||
updatedAt: "2026-05-29T08:05:00.000Z"
|
||||
),
|
||||
]
|
||||
|
||||
try await firstStore.replaceRemoteTracks(tracks)
|
||||
|
||||
let secondStore = try FileRemoteLibraryStore(fileURL: fileURL)
|
||||
let restoredTracks = try await secondStore.loadRemoteTracks()
|
||||
|
||||
XCTAssertEqual(restoredTracks, tracks)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user