From 1035e15a4c67c9d1f8828f0ba4b0e2080926616a Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Mon, 13 Dec 2021 11:01:06 -0600 Subject: [PATCH 1/2] Return true for `DatabaseError.isConnectionClosed` when `PostgresError.connectionClosed` happens. --- Sources/FluentPostgresDriver/PostgresError+Database.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/FluentPostgresDriver/PostgresError+Database.swift b/Sources/FluentPostgresDriver/PostgresError+Database.swift index 4ea2df3..4df360e 100644 --- a/Sources/FluentPostgresDriver/PostgresError+Database.swift +++ b/Sources/FluentPostgresDriver/PostgresError+Database.swift @@ -53,7 +53,12 @@ extension PostgresError: DatabaseError { } public var isConnectionClosed: Bool { - return false + switch self { + case .connectionClosed: + return true + default: + return false + } } public var isConstraintFailure: Bool { From 6a4136379f1288222c3a59937821f9b8a39a4fa4 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Mon, 13 Dec 2021 11:08:58 -0600 Subject: [PATCH 2/2] Avoids double-running the FluentBenchmark tests, adds the missing `testSQL()` benchmark test, and runs the tests when not in Xcode. --- .../FluentPostgresDriverTests.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift b/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift index cdb6a44..b96bf8b 100644 --- a/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift +++ b/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift @@ -6,9 +6,7 @@ import XCTest import PostgresKit final class FluentPostgresDriverTests: XCTestCase { - func testAll() throws { try self.benchmarker.testAll() } - - #if Xcode + //func testAll() throws { try self.benchmarker.testAll() } func testAggregate() throws { try self.benchmarker.testAggregate() } func testArray() throws { try self.benchmarker.testArray() } func testBatch() throws { try self.benchmarker.testBatch() } @@ -35,10 +33,10 @@ final class FluentPostgresDriverTests: XCTestCase { func testSiblings() throws { try self.benchmarker.testSiblings() } func testSoftDelete() throws { try self.benchmarker.testSoftDelete() } func testSort() throws { try self.benchmarker.testSort() } + func testSQL() throws { try self.benchmarker.testSQL() } func testTimestamp() throws { try self.benchmarker.testTimestamp() } func testTransaction() throws { try self.benchmarker.testTransaction() } func testUnique() throws { try self.benchmarker.testUnique() } - #endif func testDatabaseError() throws { let sql = (self.db as! SQLDatabase)