Skip the open error message test when URI filenames are off

sqlite_compileoption_used('USE_URI') reports whether the option is
defined, not its value, and is missing when compile-option diagnostics
are omitted. Check the error from the open instead: without URI
filenames, the path is in a missing "file:" directory and fails with
SQLITE_CANTOPEN.
This commit is contained in:
Sharath Kumar committed 2026-10-13 15:35:38 +05:30
1 parent 3f80cfccf4
commit e1a0c1afbe
1 file changed
+6 -7
@@ -53,15 +53,14 @@ class DatabaseQueueTests: GRDBTestCase {
}
func testOpenErrorMessage() throws {
let uriFilenamesEnabled = try DatabaseQueue().read { db in
try Bool.fetchOne(db, sql: "SELECT sqlite_compileoption_used('USE_URI')")!
}
guard uriFilenamesEnabled else {
throw XCTSkip("URI filenames are not enabled")
}
// Without URI filenames, this path is a file in a missing "file:"
// directory, and opening fails with SQLITE_CANTOPEN.
let path = "file:" + NSTemporaryDirectory() + "test.sqlite?mode=bogus"
do {
_ = try DatabaseQueue(path: "file:test.sqlite?mode=bogus")
_ = try DatabaseQueue(path: path)
XCTFail("Expected error")
} catch DatabaseError.SQLITE_CANTOPEN {
throw XCTSkip("URI filenames are not enabled")
} catch let error as DatabaseError {
XCTAssertEqual(error.resultCode, .SQLITE_ERROR)
XCTAssertEqual(error.message, "no such access mode: bogus")