Alpha 2 Update
This commit is contained in:
committed by
Dr. Michael Kübler
parent
223bf746ef
commit
8e95cc3acd
@@ -0,0 +1,39 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import MikeMail
|
||||
|
||||
@MainActor
|
||||
struct MailIdleTests {
|
||||
@Test func classifiesServerResponses() {
|
||||
#expect(IMAPClient.isMailboxChange("* 12 EXISTS"))
|
||||
#expect(IMAPClient.isMailboxChange("* 2 EXPUNGE"))
|
||||
#expect(IMAPClient.isMailboxChange("* 2 FETCH (FLAGS (\\Seen))"))
|
||||
#expect(!IMAPClient.isMailboxChange("* OK Still here"))
|
||||
#expect(!IMAPClient.isMailboxChange("M4 OK IDLE completed"))
|
||||
#expect(IMAPClient.isAuthenticationFailure("M1 NO [AUTHENTICATIONFAILED] Authentication failed."))
|
||||
#expect(IMAPClient.isAuthenticationFailure("M1 NO LOGIN failed"))
|
||||
#expect(!IMAPClient.isAuthenticationFailure("M1 NO [UNAVAILABLE] Server temporarily unavailable"))
|
||||
#expect(!IMAPClient.isAuthenticationFailure("* BYE Connection closed"))
|
||||
}
|
||||
|
||||
@Test func queuesPasswordPromptsPerAccount() 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"), b = MailAccount(name: "B")
|
||||
try archive.saveConfiguration(ArchiveConfiguration(accounts: [a, b], folders: [:], recipients: []))
|
||||
let store = MailStore(archive: archive)
|
||||
store.requestPassword(accountID: a.id)
|
||||
store.requestPassword(accountID: a.id)
|
||||
store.requestPassword(accountID: b.id)
|
||||
#expect(store.authenticationAccount?.id == a.id)
|
||||
store.dismissPasswordRequest()
|
||||
#expect(store.authenticationAccount?.id == b.id)
|
||||
store.dismissPasswordRequest()
|
||||
#expect(store.authenticationAccount == nil)
|
||||
store.requestPassword(accountID: UUID())
|
||||
#expect(store.authenticationAccount == nil)
|
||||
store.configureIdle(enabled: false)
|
||||
#expect(store.idleStatuses.isEmpty)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user