Skip to content

Commit 131e154

Browse files
authored
Make DatabaseError.isConnectionClosed functional (#187)
* Return true for `DatabaseError.isConnectionClosed` when `PostgresError.connectionClosed` happens. * Avoids double-running the FluentBenchmark tests, adds the missing `testSQL()` benchmark test, and runs the tests when not in Xcode.
1 parent a0383f0 commit 131e154

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Sources/FluentPostgresDriver/PostgresError+Database.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ extension PostgresError: DatabaseError {
5353
}
5454

5555
public var isConnectionClosed: Bool {
56-
return false
56+
switch self {
57+
case .connectionClosed:
58+
return true
59+
default:
60+
return false
61+
}
5762
}
5863

5964
public var isConstraintFailure: Bool {

Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import XCTest
66
import PostgresKit
77

88
final class FluentPostgresDriverTests: XCTestCase {
9-
func testAll() throws { try self.benchmarker.testAll() }
10-
11-
#if Xcode
9+
//func testAll() throws { try self.benchmarker.testAll() }
1210
func testAggregate() throws { try self.benchmarker.testAggregate() }
1311
func testArray() throws { try self.benchmarker.testArray() }
1412
func testBatch() throws { try self.benchmarker.testBatch() }
@@ -35,10 +33,10 @@ final class FluentPostgresDriverTests: XCTestCase {
3533
func testSiblings() throws { try self.benchmarker.testSiblings() }
3634
func testSoftDelete() throws { try self.benchmarker.testSoftDelete() }
3735
func testSort() throws { try self.benchmarker.testSort() }
36+
func testSQL() throws { try self.benchmarker.testSQL() }
3837
func testTimestamp() throws { try self.benchmarker.testTimestamp() }
3938
func testTransaction() throws { try self.benchmarker.testTransaction() }
4039
func testUnique() throws { try self.benchmarker.testUnique() }
41-
#endif
4240

4341
func testDatabaseError() throws {
4442
let sql = (self.db as! SQLDatabase)

0 commit comments

Comments
 (0)