Explicit tests that a DatabasePool can read from a new instance, and from a truncated wal file

This commit is contained in:
Gwendal Roué committed 2023-06-01 17:20:25 +02:00
1 parent d66d2118b5
commit abd3ba39b1
1 file changed
+20
+20
View File
@@ -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 {