Implement remote library metadata sync for iPhone

This commit is contained in:
diyaa
2026-05-29 08:54:09 +02:00
parent ebc187f4a1
commit 6e73c1878e
20 changed files with 1379 additions and 48 deletions
@@ -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)
}
}