From 3ccb8b5d360d8a5cb25bb5b375088fb5077ea55e Mon Sep 17 00:00:00 2001 From: Mykola Buhaiov Date: Thu, 25 Apr 2024 15:07:47 +0300 Subject: [PATCH] refactor: fix error and refactor connection --- .../PostgresHealthChecks/PostgresHealthChecks.swift | 2 +- Tests/HealthChecksTests/Mocks/PostgresHealthChecksMock.swift | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/HealthChecks/PostgresHealthChecks/PostgresHealthChecks.swift b/Sources/HealthChecks/PostgresHealthChecks/PostgresHealthChecks.swift index df0d9b4..340d574 100644 --- a/Sources/HealthChecks/PostgresHealthChecks/PostgresHealthChecks.swift +++ b/Sources/HealthChecks/PostgresHealthChecks/PostgresHealthChecks.swift @@ -49,7 +49,7 @@ public struct PostgresHealthChecks: PostgresHealthChecksProtocol { let result = HealthCheckItem( componentId: app.psqlId, componentType: .datastore, - observedValue: 1, + observedValue: connectionDescription.contains("active") ? 1 : 0, status: connectionDescription.contains("active") ? .pass : .fail, time: app.dateTimeISOFormat.string(from: Date()), output: !connectionDescription.contains("active") ? connectionDescription : nil, diff --git a/Tests/HealthChecksTests/Mocks/PostgresHealthChecksMock.swift b/Tests/HealthChecksTests/Mocks/PostgresHealthChecksMock.swift index c638545..f6072fc 100644 --- a/Tests/HealthChecksTests/Mocks/PostgresHealthChecksMock.swift +++ b/Tests/HealthChecksTests/Mocks/PostgresHealthChecksMock.swift @@ -60,4 +60,8 @@ public struct PostgresHealthChecksMock: PostgresHealthChecksProtocol { ] return result } + + public func checkConnection() async -> String { + "active" + } }