Update Helpers, Models + tests + config
Summary: - Sources: Helpers, Models - Tests: LocalDataTests.swift - Config: Package - Added symbols: enum StorageError - Removed symbols: enum StorageError Stats: - 6 files changed, 35 insertions(+), 33 deletions(-)
This commit is contained in:
parent
855ac3fdde
commit
9415edf758
@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"pins" : [
|
|
||||||
{
|
|
||||||
"identity" : "swift-syntax",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/swiftlang/swift-syntax.git",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "0687f71944021d616d34d922343dcef086855920",
|
|
||||||
"version" : "600.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identity" : "swift-testing",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/apple/swift-testing.git",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "399f76dcd91e4c688ca2301fa24a8cc6d9927211",
|
|
||||||
"version" : "0.99.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version" : 2
|
|
||||||
}
|
|
||||||
@ -15,9 +15,7 @@ let package = Package(
|
|||||||
targets: ["LocalData"]
|
targets: ["LocalData"]
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [],
|
||||||
.package(url: "https://github.com/apple/swift-testing.git", from: "0.7.0")
|
|
||||||
],
|
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
name: "LocalData"
|
name: "LocalData"
|
||||||
@ -25,8 +23,7 @@ let package = Package(
|
|||||||
.testTarget(
|
.testTarget(
|
||||||
name: "LocalDataTests",
|
name: "LocalDataTests",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
"LocalData",
|
"LocalData"
|
||||||
.product(name: "Testing", package: "swift-testing")
|
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -207,7 +207,7 @@ actor FileStorageHelper {
|
|||||||
)
|
)
|
||||||
} catch {
|
} catch {
|
||||||
Logger.error("Failed to create directory", error: error)
|
Logger.error("Failed to create directory", error: error)
|
||||||
throw StorageError.fileError(error)
|
throw StorageError.fileError(error.localizedDescription)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ actor FileStorageHelper {
|
|||||||
Logger.debug("Successfully wrote \(data.count) bytes to \(url.lastPathComponent)")
|
Logger.debug("Successfully wrote \(data.count) bytes to \(url.lastPathComponent)")
|
||||||
} catch {
|
} catch {
|
||||||
Logger.error("Failed to write to \(url.path)", error: error)
|
Logger.error("Failed to write to \(url.path)", error: error)
|
||||||
throw StorageError.fileError(error)
|
throw StorageError.fileError(error.localizedDescription)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,9 +22,11 @@ public enum KeychainAccessibility: Sendable, CaseIterable {
|
|||||||
|
|
||||||
/// Item is always accessible, regardless of device lock state.
|
/// Item is always accessible, regardless of device lock state.
|
||||||
/// Least secure - use only when absolutely necessary.
|
/// Least secure - use only when absolutely necessary.
|
||||||
|
@available(iOS, deprecated: 12.0, message: "Use an accessibility level that provides some user protection, such as afterFirstUnlock")
|
||||||
case always
|
case always
|
||||||
|
|
||||||
/// Item is always accessible but not migrated to new devices.
|
/// Item is always accessible but not migrated to new devices.
|
||||||
|
@available(iOS, deprecated: 12.0, message: "Use an accessibility level that provides some user protection, such as afterFirstUnlockThisDeviceOnly")
|
||||||
case alwaysThisDeviceOnly
|
case alwaysThisDeviceOnly
|
||||||
|
|
||||||
/// Item is only accessible when the device has a passcode set.
|
/// Item is only accessible when the device has a passcode set.
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public enum StorageError: Error {
|
public enum StorageError: Error, Equatable {
|
||||||
case serializationFailed, deserializationFailed
|
case serializationFailed, deserializationFailed
|
||||||
case securityApplicationFailed
|
case securityApplicationFailed
|
||||||
case keychainError(OSStatus)
|
case keychainError(OSStatus)
|
||||||
case fileError(Error)
|
case fileError(String) // Changed from Error to String for easier Equatable conformance
|
||||||
case phoneOnlyKeyAccessedOnWatch(String)
|
case phoneOnlyKeyAccessedOnWatch(String)
|
||||||
case watchOnlyKeyAccessedOnPhone(String)
|
case watchOnlyKeyAccessedOnPhone(String)
|
||||||
case invalidUserDefaultsSuite(String)
|
case invalidUserDefaultsSuite(String)
|
||||||
@ -14,6 +14,32 @@ public enum StorageError: Error {
|
|||||||
case unregisteredKey(String)
|
case unregisteredKey(String)
|
||||||
case duplicateRegisteredKeys([String])
|
case duplicateRegisteredKeys([String])
|
||||||
case missingDescription(String)
|
case missingDescription(String)
|
||||||
|
|
||||||
|
public static func == (lhs: StorageError, rhs: StorageError) -> Bool {
|
||||||
|
switch (lhs, rhs) {
|
||||||
|
case (.serializationFailed, .serializationFailed),
|
||||||
|
(.deserializationFailed, .deserializationFailed),
|
||||||
|
(.securityApplicationFailed, .securityApplicationFailed),
|
||||||
|
(.dataTooLargeForSync, .dataTooLargeForSync),
|
||||||
|
(.notFound, .notFound):
|
||||||
|
return true
|
||||||
|
case (.keychainError(let l), .keychainError(let r)):
|
||||||
|
return l == r
|
||||||
|
case (.fileError(let l), .fileError(let r)):
|
||||||
|
return l == r
|
||||||
|
case (.phoneOnlyKeyAccessedOnWatch(let l), .phoneOnlyKeyAccessedOnWatch(let r)),
|
||||||
|
(.watchOnlyKeyAccessedOnPhone(let l), .watchOnlyKeyAccessedOnPhone(let r)),
|
||||||
|
(.invalidUserDefaultsSuite(let l), .invalidUserDefaultsSuite(let r)),
|
||||||
|
(.invalidAppGroupIdentifier(let l), .invalidAppGroupIdentifier(let r)),
|
||||||
|
(.unregisteredKey(let l), .unregisteredKey(let r)),
|
||||||
|
(.missingDescription(let l), .missingDescription(let r)):
|
||||||
|
return l == r
|
||||||
|
case (.duplicateRegisteredKeys(let l), .duplicateRegisteredKeys(let r)):
|
||||||
|
return l == r
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension StorageError: @unchecked Sendable {}
|
extension StorageError: @unchecked Sendable {}
|
||||||
|
|||||||
@ -56,7 +56,7 @@ struct LocalDataTests {
|
|||||||
#expect(fetched == storedValue)
|
#expect(fetched == storedValue)
|
||||||
|
|
||||||
try await StorageRouter.shared.remove(key)
|
try await StorageRouter.shared.remove(key)
|
||||||
await #expect(throws: StorageError.notFound) {
|
#expect(throws: StorageError.notFound) {
|
||||||
_ = try await StorageRouter.shared.get(key)
|
_ = try await StorageRouter.shared.get(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user