From e1a0c1afbe77e145c72712c44ede4c09ea1c2d82 Mon Sep 17 00:00:00 2001 From: Sharath Kumar <7642133+builtbysharath@users.noreply.github.com> Date: Tue, 13 Oct 2026 15:35:38 +0530 Subject: [PATCH] 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. --- .../Core/DatabaseQueue/DatabaseQueueTests.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Tests/GRDBTests/Core/DatabaseQueue/DatabaseQueueTests.swift b/Tests/GRDBTests/Core/DatabaseQueue/DatabaseQueueTests.swift index 11dff10ac..fd870adca 100644 --- a/Tests/GRDBTests/Core/DatabaseQueue/DatabaseQueueTests.swift +++ b/Tests/GRDBTests/Core/DatabaseQueue/DatabaseQueueTests.swift @@ -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")