WHAT TO BACK UP section: - Remove "New files only" / "Skip files already on NAS" toggle from Settings - Remove BackupFilter.newFilesOnly field — duplicate protection is always active (fileExists pre-check + hybrid filterIndex ensure NAS files are never re-uploaded) NOTIFICATIONS section: - Replace static decorative rows with real ToggleRow controls backed by ConnectionStore (notifyOnStart=false, notifyOnComplete=true, notifyOnErrors=true) - BackupEngine now gates notification calls behind these store flags NETWORK section: - WiFi row always shows ● On / ● Off indicator (was only shown when SSID known) - Shows "Trusted" / "Unknown" when SSID is available, "On" / "Off" otherwise Tests: - makeAssets: add missing isScreenRecording parameter - Rename test_backup_skipsExistingFiles_whenNewFilesOnly → _alwaysHardcoded, remove filter.newFilesOnly assignment - MockNASService: add downloadData, writeData, deleteFile to satisfy protocol Co-Authored-By: Kutesir <kutesir@provoc.ug> Co-Authored-By: Sentry <sentry@provoc.ug>
62 lines
1.8 KiB
Swift
62 lines
1.8 KiB
Swift
import Foundation
|
|
@testable import NASBackup
|
|
|
|
final class MockNASService: NASTransferProtocol {
|
|
var shouldFail: Bool = false
|
|
var uploadDelay: TimeInterval = 0
|
|
var fakeItems: [NASItem] = []
|
|
var fileExistsAnswer: Bool = false
|
|
|
|
private(set) var connectCalled = false
|
|
private(set) var uploadCallCount = 0
|
|
private(set) var lastUploadedPath: String?
|
|
|
|
var isConnected: Bool = false
|
|
|
|
func connect(to host: String, port: Int, username: String, password: String) async throws {
|
|
connectCalled = true
|
|
if shouldFail { throw MockError.connectionFailed }
|
|
isConnected = true
|
|
}
|
|
|
|
func disconnect() { isConnected = false }
|
|
|
|
func listShares() async throws -> [String] { [] }
|
|
|
|
func listDirectory(at path: String) async throws -> [NASItem] {
|
|
if shouldFail { throw MockError.connectionFailed }
|
|
return fakeItems
|
|
}
|
|
|
|
func createDirectory(at path: String) async throws {
|
|
if shouldFail { throw MockError.connectionFailed }
|
|
}
|
|
|
|
func fileExists(at remotePath: String) async throws -> Bool { fileExistsAnswer }
|
|
|
|
func downloadData(at remotePath: String) async throws -> Data { Data() }
|
|
|
|
func writeData(_ data: Data, to remotePath: String) async throws {
|
|
if shouldFail { throw MockError.uploadFailed }
|
|
}
|
|
|
|
func deleteFile(at remotePath: String) async throws {
|
|
if shouldFail { throw MockError.uploadFailed }
|
|
}
|
|
|
|
func upload(localURL: URL, remotePath: String, progress: @escaping (Int64, Int64) -> Void) async throws {
|
|
if uploadDelay > 0 {
|
|
try await Task.sleep(nanoseconds: UInt64(uploadDelay * 1_000_000_000))
|
|
}
|
|
if shouldFail { throw MockError.uploadFailed }
|
|
progress(100, 100)
|
|
uploadCallCount += 1
|
|
lastUploadedPath = remotePath
|
|
}
|
|
}
|
|
|
|
enum MockError: Error {
|
|
case connectionFailed
|
|
case uploadFailed
|
|
}
|