From abd3ba39b1b38550986983acc2adab238eb8be33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Rou=C3=A9?= Date: Thu, 1 Jun 2023 17:20:25 +0200 Subject: [PATCH] Explicit tests that a DatabasePool can read from a new instance, and from a truncated wal file --- Tests/GRDBTests/DatabasePoolTests.swift | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Tests/GRDBTests/DatabasePoolTests.swift b/Tests/GRDBTests/DatabasePoolTests.swift index 22813d232..379bb5a98 100644 --- a/Tests/GRDBTests/DatabasePoolTests.swift +++ b/Tests/GRDBTests/DatabasePoolTests.swift @@ -11,6 +11,26 @@ class DatabasePoolTests: GRDBTestCase { } } + func testCanReadFromNewInstance() throws { + let dbPool = try makeDatabasePool() + try dbPool.read { _ in } + } + + func testCanReadFromTruncatedWalFile() throws { + do { + let dbPool = try makeDatabasePool(filename: "test") + try dbPool.writeWithoutTransaction { db in + try db.execute(sql: "CREATE TABLE t(a)") + try db.checkpoint(.truncate) + } + } + do { + let dbPool = try makeDatabasePool(filename: "test") + let count = try dbPool.read(Table("t").fetchCount) + XCTAssertEqual(count, 0) + } + } + func testPersistentWALModeEnabled() throws { let path: String do {