Skip to content

Commit 8952103

Browse files
authored
Throw errors instead of crashing when things go wrong during test setup, such as failure to connect to the database. (#144)
1 parent a7b7e34 commit 8952103

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ final class FluentPostgresDriverTests: XCTestCase {
168168
self.db as! PostgresDatabase
169169
}
170170

171-
override func setUp() {
171+
override func setUpWithError() throws {
172+
try super.setUpWithError()
173+
172174
let configuration = PostgresConfiguration(
173175
hostname: hostname,
174176
username: "vapor_username",
@@ -182,14 +184,15 @@ final class FluentPostgresDriverTests: XCTestCase {
182184
self.dbs.use(.postgres(configuration: configuration), as: .psql)
183185

184186
// reset the database
185-
_ = try! self.postgres.query("drop schema public cascade").wait()
186-
_ = try! self.postgres.query("create schema public").wait()
187+
_ = try self.postgres.query("drop schema public cascade").wait()
188+
_ = try self.postgres.query("create schema public").wait()
187189
}
188190

189-
override func tearDown() {
191+
override func tearDownWithError() throws {
190192
self.dbs.shutdown()
191-
try! self.threadPool.syncShutdownGracefully()
192-
try! self.eventLoopGroup.syncShutdownGracefully()
193+
try self.threadPool.syncShutdownGracefully()
194+
try self.eventLoopGroup.syncShutdownGracefully()
195+
try super.tearDownWithError()
193196
}
194197
}
195198

0 commit comments

Comments
 (0)