Alpha 2 Update

This commit is contained in:
Dr. Michael Kübler
2026-11-07 12:24:11 +01:00
committed by Dr. Michael Kübler
parent 223bf746ef
commit 8e95cc3acd
22 changed files with 1935 additions and 144 deletions
+40
View File
@@ -55,6 +55,46 @@ struct MailArchiveTests {
#expect(!FileManager.default.fileExists(atPath: base.appending(path: "Rejected").path))
}
@Test func localResetIsAccountScopedAndForcesRedownload() async throws {
let root = FileManager.default.temporaryDirectory.appending(path: UUID().uuidString)
defer { try? FileManager.default.removeItem(at: root) }
let archive = try MailArchive(root: root)
let a = MailAccount(name: "A", email: "a@example.com", username: "a", host: "example.com")
let b = MailAccount(name: "B", email: "b@example.com", username: "b", host: "example.com")
let inboxA = MailFolder(accountID: a.id, path: "INBOX", name: "Posteingang")
let inboxB = MailFolder(accountID: b.id, path: "INBOX", name: "Posteingang")
let hiddenA = MailFolder(accountID: a.id, path: "OldFolder", name: "Alt")
let outgoingA = MailFolder(accountID: a.id, path: "__local_outgoing__", name: "Versand")
let shared = Data("Subject: Shared\r\n\r\nShared body".utf8)
let unique = Data("Subject: Local\r\n\r\nOnly A".utf8)
try archive.saveConfiguration(ArchiveConfiguration(accounts: [a, b], folders: [a.id: [inboxA], b.id: [inboxB]], recipients: ["x@example.com"]))
try archive.store(raw: shared, folderID: inboxA.id, validity: "1", uid: "1", flags: [])
try archive.store(raw: shared, folderID: inboxB.id, validity: "1", uid: "1", flags: [])
try archive.store(raw: unique, folderID: hiddenA.id, validity: "old", uid: "2", flags: [], visible: false)
try archive.store(raw: unique, folderID: outgoingA.id, validity: "local", uid: "pending", flags: ["Pending"])
let store = MailStore(archive: archive)
await store.load(folderID: inboxA.id)
#expect(store.messages.count == 1)
store.isBusy = true
#expect(throws: (any Error).self) { try store.clearLocalMessages(accountID: a.id) }
#expect(try archive.knownUIDs(folderID: inboxA.id, validity: "1") == [1])
store.isBusy = false
#expect(try store.clearLocalMessages(accountID: a.id) == 0)
#expect(store.messages.isEmpty)
#expect(store.accounts == [a, b])
#expect(try archive.configuration()?.folders[a.id] == [inboxA])
#expect(try archive.knownUIDs(folderID: inboxA.id, validity: "1").isEmpty)
#expect(try archive.knownUIDs(folderID: hiddenA.id, validity: "old").isEmpty)
#expect(try archive.messages(folderID: outgoingA.id).isEmpty)
#expect(try archive.messages(folderID: inboxB.id).count == 1)
#expect(FileManager.default.fileExists(atPath: root.appending(path: "Objects/\(MailArchive.digest(shared)).eml").path))
#expect(!FileManager.default.fileExists(atPath: root.appending(path: "Objects/\(MailArchive.digest(unique)).eml").path))
let reopened = try MailArchive(root: root)
#expect(try reopened.knownUIDs(folderID: inboxA.id, validity: "1").isEmpty)
try reopened.store(raw: shared, folderID: inboxA.id, validity: "1", uid: "1", flags: [])
#expect(try reopened.messages(folderID: inboxA.id).count == 1)
}
@Test func imapInventoryParsing() throws {
#expect(try IMAPClient.uidValidity(from: ["* OK [UIDVALIDITY 123] UIDs valid"]) == "123")
#expect(throws: (any Error).self) { try IMAPClient.uidValidity(from: ["* OK hello"]) }