mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
Test that prepareDatabase errors are rethrown
This commit is contained in:
1 parent
1f48405b5c
commit
d4928eff99
1 file changed
+43
@@ -29,4 +29,47 @@ class DatabaseConfigurationTests: GRDBTestCase {
|
||||
try pool.makeSnapshot().read { _ in }
|
||||
XCTAssertEqual(connectionCount, 5)
|
||||
}
|
||||
|
||||
func testPrepareDatabaseError() throws {
|
||||
struct TestError: Error { }
|
||||
var error: TestError?
|
||||
|
||||
var configuration = Configuration()
|
||||
configuration.prepareDatabase = { db in
|
||||
if let error = error {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: what about in-memory DatabaseQueue???
|
||||
|
||||
do {
|
||||
error = TestError()
|
||||
_ = try makeDatabaseQueue(configuration: configuration)
|
||||
XCTFail("Expected TestError")
|
||||
} catch is TestError { }
|
||||
|
||||
do {
|
||||
error = TestError()
|
||||
_ = try makeDatabasePool(configuration: configuration)
|
||||
XCTFail("Expected TestError")
|
||||
} catch is TestError { }
|
||||
|
||||
do {
|
||||
error = nil
|
||||
let pool = try makeDatabasePool(configuration: configuration)
|
||||
|
||||
do {
|
||||
error = TestError()
|
||||
try pool.read { _ in }
|
||||
XCTFail("Expected TestError")
|
||||
} catch is TestError { }
|
||||
|
||||
do {
|
||||
error = TestError()
|
||||
_ = try pool.makeSnapshot()
|
||||
XCTFail("Expected TestError")
|
||||
} catch is TestError { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user