This commit is contained in:
@@ -14,7 +14,6 @@ import ServiceLifecycleTestKit
|
||||
import XCTest
|
||||
|
||||
final class IntegrationTests: XCTestCase {
|
||||
|
||||
static let hostname = ProcessInfo.processInfo.environment["MOSQUITTO_SERVER"] ?? "localhost"
|
||||
|
||||
static let logger: Logger = {
|
||||
@@ -25,7 +24,6 @@ final class IntegrationTests: XCTestCase {
|
||||
|
||||
override func invokeTest() {
|
||||
let client = createClient(identifier: "\(Self.self)")
|
||||
|
||||
withDependencies {
|
||||
$0.mqtt = .live(client: client, logger: Self.logger)
|
||||
$0.psychrometricClient = PsychrometricClient.liveValue
|
||||
@@ -36,24 +34,27 @@ final class IntegrationTests: XCTestCase {
|
||||
|
||||
func testConnectionServiceShutdown() async throws {
|
||||
@Dependency(\.mqtt) var mqtt
|
||||
do {
|
||||
let service = MQTTConnectionService(logger: Self.logger)
|
||||
let task = Task { try await service.run() }
|
||||
defer { task.cancel() }
|
||||
|
||||
let service = MQTTConnectionService(logger: Self.logger)
|
||||
let task = Task { try await service.run() }
|
||||
defer { task.cancel() }
|
||||
try await Task.sleep(for: .milliseconds(200))
|
||||
|
||||
try await Task.sleep(for: .milliseconds(200))
|
||||
// check the connection is active here.
|
||||
try await mqtt.withClient { client in
|
||||
XCTAssert(client.isActive())
|
||||
}
|
||||
mqtt.shutdown()
|
||||
|
||||
// check the connection is active here.
|
||||
try await mqtt.withClient { client in
|
||||
XCTAssert(client.isActive())
|
||||
}
|
||||
mqtt.shutdown()
|
||||
|
||||
try await Task.sleep(for: .milliseconds(500))
|
||||
|
||||
// check the connection is active here.
|
||||
try await mqtt.withClient { client in
|
||||
XCTAssertFalse(client.isActive())
|
||||
try await Task.sleep(for: .milliseconds(500))
|
||||
// check the connection is active here.
|
||||
try await mqtt.withClient { client in
|
||||
XCTAssertFalse(client.isActive())
|
||||
}
|
||||
} catch {
|
||||
mqtt.shutdown()
|
||||
try await Task.sleep(for: .milliseconds(500))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,11 +189,9 @@ final class IntegrationTests: XCTestCase {
|
||||
configuration: config
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// - MARK: Helpers
|
||||
|
||||
struct TopicNotFoundError: Error {}
|
||||
|
||||
actor ResultContainer: Sendable {
|
||||
|
||||
Reference in New Issue
Block a user