47 lines
1.2 KiB
Swift
47 lines
1.2 KiB
Swift
import Testing
|
|
@testable import IMAPClient
|
|
import NIOIMAPCore
|
|
|
|
@Suite("IMAP Response Parsing")
|
|
struct IMAPResponseParsingTests {
|
|
@Test("IMAPClient can be instantiated and conforms to protocol")
|
|
func instantiation() {
|
|
let client = IMAPClient(
|
|
host: "imap.example.com",
|
|
port: 993,
|
|
credentials: .init(username: "user", password: "pass")
|
|
)
|
|
let _: any IMAPClientProtocol = client
|
|
}
|
|
|
|
@Test("tag counter increments across commands")
|
|
func tagCounterIncrements() async {
|
|
let connection = IMAPConnection(host: "localhost", port: 993)
|
|
var runner = IMAPCommandRunner(connection: connection)
|
|
#expect(runner.nextTag() == "A1")
|
|
#expect(runner.nextTag() == "A2")
|
|
#expect(runner.nextTag() == "A3")
|
|
}
|
|
|
|
@Test("IMAPError cases are Sendable")
|
|
func errorSendability() {
|
|
let error: any Error & Sendable = IMAPError.notConnected
|
|
#expect(error is IMAPError)
|
|
}
|
|
|
|
@Test("IMAPError has expected cases")
|
|
func errorCases() {
|
|
let errors: [any Error] = [
|
|
IMAPError.notConnected,
|
|
IMAPError.authenticationFailed,
|
|
IMAPError.serverError("test"),
|
|
IMAPError.unexpectedResponse("bad data"),
|
|
]
|
|
|
|
for error in errors {
|
|
#expect(error is IMAPError)
|
|
}
|
|
#expect(errors.count == 4)
|
|
}
|
|
}
|