feat: Working on cli client and tests
Some checks failed
CI / Run Tests (push) Failing after 3m7s

This commit is contained in:
2024-11-17 22:23:44 -05:00
parent 6472d3cd1e
commit ce18c44363
12 changed files with 287 additions and 73 deletions

View File

@@ -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 {