WP-0: SwiftPM scaffold, shared model, signed app bundle script
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
import ShotdeckCore
|
||||
|
||||
@Test
|
||||
func appSupportPathsCreatesEveryNamedDirectory() throws {
|
||||
let temporaryRoot = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("shotdeck-paths-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager.default.removeItem(at: temporaryRoot) }
|
||||
|
||||
let root = temporaryRoot.appendingPathComponent("root", isDirectory: true)
|
||||
let outbox = temporaryRoot.appendingPathComponent("outbox", isDirectory: true)
|
||||
let watchFolder = temporaryRoot.appendingPathComponent("watch", isDirectory: true)
|
||||
|
||||
let paths = try AppSupportPaths(root: root, outbox: outbox, watchFolder: watchFolder)
|
||||
|
||||
#expect(directoryExists(paths.root))
|
||||
#expect(directoryExists(paths.spool))
|
||||
#expect(directoryExists(paths.archive))
|
||||
#expect(directoryExists(paths.outbox))
|
||||
#expect(directoryExists(paths.watchFolder))
|
||||
|
||||
#expect(paths.spool.path == root.appendingPathComponent("spool", isDirectory: true).path)
|
||||
#expect(paths.archive.path == root.appendingPathComponent("archive", isDirectory: true).path)
|
||||
}
|
||||
|
||||
@Test
|
||||
func sessionAndArchiveDirectoriesAreDistinctUnderTheRightParents() throws {
|
||||
let temporaryRoot = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("shotdeck-dirs-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager.default.removeItem(at: temporaryRoot) }
|
||||
|
||||
let paths = try AppSupportPaths(
|
||||
root: temporaryRoot.appendingPathComponent("root", isDirectory: true),
|
||||
outbox: temporaryRoot.appendingPathComponent("outbox", isDirectory: true),
|
||||
watchFolder: temporaryRoot.appendingPathComponent("watch", isDirectory: true)
|
||||
)
|
||||
|
||||
let sessionID = UUID()
|
||||
let sessionDirectory = paths.sessionDirectory(sessionID)
|
||||
let archiveDirectory = paths.archiveDirectory(sessionID)
|
||||
|
||||
#expect(sessionDirectory.path != archiveDirectory.path)
|
||||
#expect(sessionDirectory.deletingLastPathComponent().path == paths.spool.path)
|
||||
#expect(archiveDirectory.deletingLastPathComponent().path == paths.archive.path)
|
||||
#expect(sessionDirectory.lastPathComponent == sessionID.uuidString)
|
||||
#expect(archiveDirectory.lastPathComponent == sessionID.uuidString)
|
||||
}
|
||||
|
||||
@Test
|
||||
func dubaiTimeStampRendersAKnownInstantInAsiaDubai() throws {
|
||||
var calendar = Calendar(identifier: .gregorian)
|
||||
let dubai = try #require(TimeZone(identifier: "Asia/Dubai"))
|
||||
calendar.timeZone = dubai
|
||||
|
||||
let date = try #require(
|
||||
calendar.date(from: DateComponents(
|
||||
year: 2026,
|
||||
month: 8,
|
||||
day: 30,
|
||||
hour: 13,
|
||||
minute: 42,
|
||||
second: 5
|
||||
))
|
||||
)
|
||||
|
||||
#expect(DubaiTime.stamp(date) == "30 Aug 2026, 13:42 Dubai")
|
||||
#expect(DubaiTime.fileStamp(date) == "20260830-134205")
|
||||
}
|
||||
|
||||
private func directoryExists(_ url: URL) -> Bool {
|
||||
var isDirectory: ObjCBool = false
|
||||
let exists = FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory)
|
||||
return exists && isDirectory.boolValue
|
||||
}
|
||||
Reference in New Issue
Block a user