new app store assets ready for relese
This commit is contained in:
@@ -111,7 +111,7 @@ final class MockProtocol: URLProtocol, @unchecked Sendable {
|
||||
for failure in [URLError(.cancelled), URLError(.timedOut)] {
|
||||
MockProtocol.handler = { _ in throw failure }
|
||||
await model.loadPreferences()
|
||||
check((model.error != nil) == (failure.code == .timedOut), "Only expected cancellation is silent: \(failure.code)")
|
||||
check(model.error != nil, "Unexpected active-session cancellation and timeout remain visible: \(failure.code)")
|
||||
check(model.preferences["save_path"] as? String == "/downloads", "Failed reload retains preferences")
|
||||
}
|
||||
model.error = nil
|
||||
@@ -229,14 +229,16 @@ final class MockProtocol: URLProtocol, @unchecked Sendable {
|
||||
check(history.samples.count == 2, "Out-of-order speed samples cannot corrupt the timeline")
|
||||
history.record(download: 300, upload: 30, at: origin.addingTimeInterval(30))
|
||||
check(history.samples.last?.segment == 1, "Background and network gaps start a new chart segment")
|
||||
history.record(download: 400, upload: 40, at: origin.addingTimeInterval(1000))
|
||||
check(history.samples.count == 1, "History expires samples older than fifteen minutes")
|
||||
history.record(download: 400, upload: 40, at: origin.addingTimeInterval(86_431))
|
||||
check(history.samples.count == 1, "History expires samples older than 24 hours")
|
||||
var dense = TransferHistory()
|
||||
for second in 0...700 { dense.record(download: 1, upload: 2, at: origin.addingTimeInterval(Double(second))) }
|
||||
for second in 0...86_500 { dense.record(download: 1, upload: 2, at: origin.addingTimeInterval(Double(second))) }
|
||||
check(dense.samples.count == TransferHistory.maximumSamples, "History storage remains bounded during frequent refreshes")
|
||||
check(model.transferHistory.samples.isEmpty, "Disconnected session has no previous server history")
|
||||
let historyTransport = try Transport(Credentials(server: "https://example.test"), configuration: config)
|
||||
let liveHistory = AppModel()
|
||||
liveHistory.historyStore = HistoryStore(url: URL(fileURLWithPath: ProcessInfo.processInfo.environment["TARNAX_SCRATCH_ROOT"]!).appendingPathComponent("test-history.json"))
|
||||
defer { try? liveHistory.historyStore.clear() }
|
||||
liveHistory.client = historyTransport; liveHistory.connected = true; liveHistory.locked = false
|
||||
MockProtocol.handler = { request in
|
||||
if request.url!.path.hasSuffix("torrents/info") { return (200, "[]") }
|
||||
@@ -253,6 +255,21 @@ final class MockProtocol: URLProtocol, @unchecked Sendable {
|
||||
for second in [0, 3, 6] { windowHistory.record(download: 1, upload: 2, at: origin.addingTimeInterval(Double(second))) }
|
||||
check(windowHistory.samples(from: origin.addingTimeInterval(3), through: origin.addingTimeInterval(6)).count == 2, "History window includes exact timestamp boundaries without new Date comparison entry points")
|
||||
check(windowHistory.samples(from: origin.addingTimeInterval(7), through: origin.addingTimeInterval(9)).isEmpty, "History window excludes samples outside its numeric time range")
|
||||
let temp = URL(fileURLWithPath: ProcessInfo.processInfo.environment["TARNAX_SCRATCH_ROOT"]!).appendingPathComponent(UUID().uuidString).appendingPathComponent("history.json")
|
||||
let store = HistoryStore(url: temp)
|
||||
defer { try? FileManager.default.removeItem(at: temp.deletingLastPathComponent()) }
|
||||
let scope = Credentials(server: "https://history.test", username: "alice")
|
||||
try store.save(windowHistory, for: scope)
|
||||
let restored = try store.load(for: scope, at: origin.addingTimeInterval(6))
|
||||
check(restored.samples.count == 3 && restored.samples.first?.download == 1, "History round trips timestamps and speeds across store instances")
|
||||
check(try store.load(for: Credentials(server: "https://other.test"), at: origin).samples.isEmpty, "History never crosses server identities")
|
||||
check(try store.load(for: scope, at: origin.addingTimeInterval(90_000)).samples.isEmpty, "Restoration prunes expired history")
|
||||
try store.clear()
|
||||
check(!FileManager.default.fileExists(atPath: temp.path), "Forgetting removes persistent history")
|
||||
check(duration(45) == "45 sec" && duration(90) == "1.5 min" && duration(7200) == "2 hr", "Duration formatting retains seconds and scales to minutes and hours")
|
||||
check(StatFormat.display(120, key: "max_seeding_time", preference: true) == "2 hr", "Seeding preferences convert API minutes correctly")
|
||||
check(StatFormat.display(42, key: "total_peers") == "42", "Unit metadata leaves counters untouched")
|
||||
check(StatFormat.display(1024, key: "dl_info_speed").hasSuffix("/s"), "Speeds retain per-second units")
|
||||
another.close(); transport.close(); print("\(checks) contract checks passed.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user