Skip to content

Commit

Permalink
fix: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gulivero1773 committed Apr 30, 2024
1 parent 6f82c28 commit 05cdf0d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Sources/HealthChecks/MongoHealthChecks/MongoRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public struct MongoRequest: MongoRequestSendable {
/// - Returns: `String`
public func getConnection(by url: String) async throws -> String {
app.mongoCluster = try? await MongoCluster(connectingTo: ConnectionSettings(url))
return "\(app.mongoCluster?.connectionState ?? .disconnected)"
let connection = "\(app.mongoCluster?.connectionState ?? .disconnected)"
await app.mongoCluster?.disconnect()
return connection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public struct PostgresHealthChecks: PostgresHealthChecksProtocol {
let result = HealthCheckItem(
componentId: app.psqlId,
componentType: .datastore,
observedValue: connectionDescription.contains("active") ? 1 : nil,
status: connectionDescription.contains("active") ? .pass : .fail,
time: app.dateTimeISOFormat.string(from: Date()),
output: !connectionDescription.contains("active") ? connectionDescription : nil,
Expand Down
2 changes: 0 additions & 2 deletions Tests/HealthChecksTests/PostgresHealthChecksTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ final class PostgresHealthChecksTests: XCTestCase {
app.psqlHealthChecks = PostgresHealthChecks(app: app, postgresDatabase: "test")
let result = await app.psqlHealthChecks?.connection()
XCTAssertEqual(result?.componentType, .datastore)
XCTAssertEqual(result?.observedValue, 1)
XCTAssertEqual(result?.status, .pass)
XCTAssertNil(result?.affectedEndpoints)
XCTAssertNil(result?.output)
Expand Down Expand Up @@ -82,7 +81,6 @@ final class PostgresHealthChecksTests: XCTestCase {
let result = await app.psqlHealthChecks?.check(for: [MeasurementType.responseTime, MeasurementType.connections])
let psqlConnections = result?["\(ComponentName.postgresql):\(MeasurementType.connections)"]
XCTAssertEqual(psqlConnections?.componentType, .datastore)
XCTAssertEqual(psqlConnections?.observedValue, 1)
XCTAssertEqual(psqlConnections?.status, .pass)
XCTAssertNil(psqlConnections?.affectedEndpoints)
XCTAssertNil(psqlConnections?.output)
Expand Down

0 comments on commit 05cdf0d

Please sign in to comment.