27 lines
991 B
Swift
27 lines
991 B
Swift
|
|
import XCTest
|
||
|
|
@testable import LCEssentials
|
||
|
|
|
||
|
|
final class APIActorTests: XCTestCase {
|
||
|
|
|
||
|
|
func testAPIIsAnActorNotMainActorBound() async {
|
||
|
|
let isActor = (API.shared as Any) is any Actor
|
||
|
|
XCTAssertTrue(isActor, "API must be an actor so callers are not forced onto the main thread")
|
||
|
|
}
|
||
|
|
|
||
|
|
func testPersistConnectionDelayRoundTrips() async {
|
||
|
|
let api = API(testConfiguration: .ephemeral)
|
||
|
|
await api.setPersistConnectionDelay(9)
|
||
|
|
let value = await api.persistConnectionDelay
|
||
|
|
XCTAssertEqual(value, 9)
|
||
|
|
}
|
||
|
|
|
||
|
|
func testIsolatedTestInstanceDoesNotTouchSharedCertState() async {
|
||
|
|
let api = API(testConfiguration: .ephemeral)
|
||
|
|
await api.setupCertification(certData: Data([0x01, 0x02]), password: "pw")
|
||
|
|
let sharedHasCert = await API.shared.hasClientCertificateConfigured
|
||
|
|
let instanceHasCert = await api.hasClientCertificateConfigured
|
||
|
|
XCTAssertFalse(sharedHasCert)
|
||
|
|
XCTAssertTrue(instanceHasCert)
|
||
|
|
}
|
||
|
|
}
|