Skip to content

Commit

Permalink
Failing test for groue#931
Browse files Browse the repository at this point in the history
  • Loading branch information
groue authored and Eric Vitiello committed Aug 25, 2021
1 parent c5db6fe commit 6225284
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Tests/GRDBTests/DatabasePoolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,27 @@ class DatabasePoolTests: GRDBTestCase {
XCTAssertFalse(fm.fileExists(atPath: path + "-wal"))
XCTAssertFalse(fm.fileExists(atPath: path + "-shm"))
}

// Regression test
func testIssue931() throws {
dbConfiguration.prepareDatabase { db in
var flag: CInt = 0
let code = withUnsafeMutablePointer(to: &flag) { flagP in
sqlite3_file_control(db.sqliteConnection, nil, SQLITE_FCNTL_PERSIST_WAL, flagP)
}
guard code == SQLITE_OK else {
throw DatabaseError(resultCode: ResultCode(rawValue: code))
}
}
let dbQueue = try makeDatabaseQueue()

var migrator = DatabaseMigrator()
migrator.registerMigration("v1", migrate: { _ in })
migrator.eraseDatabaseOnSchemaChange = true
try migrator.migrate(dbQueue)

// Trigger #931: the migrator creates a temporary database and
// calls `sqlite3_file_control` as part of the preparation function.
try migrator.migrate(dbQueue)
}
}

0 comments on commit 6225284

Please sign in to comment.