mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
This enables easier compilation of a custom version of SQLite that itself uses the SQLITE_HAS_CODEC define. (ex. If building SQLite with the SQLite Encryption Extension.) The SQLITE_HAS_CODEC define is now only used to guard use of the SQLite encryption APIs. GRDBCipher builds define USING_BUILTIN_SQLITE and USING_SQLCIPHER.
41 lines
1.2 KiB
Swift
41 lines
1.2 KiB
Swift
import XCTest
|
|
#if USING_SQLCIPHER
|
|
import GRDBCipher
|
|
#elseif USING_CUSTOMSQLITE
|
|
import GRDBCustomSQLite
|
|
#else
|
|
import GRDB
|
|
#endif
|
|
|
|
class DatabaseQueueBackupTests: GRDBTestCase {
|
|
|
|
func testBackup() {
|
|
assertNoError {
|
|
let source = try makeDatabaseQueue("source.sqlite")
|
|
let destination = try makeDatabaseQueue("destination.sqlite")
|
|
|
|
try source.inDatabase { db in
|
|
try db.execute("CREATE TABLE items (id INTEGER PRIMARY KEY)")
|
|
try db.execute("INSERT INTO items (id) VALUES (NULL)")
|
|
XCTAssertEqual(Int.fetchOne(db, "SELECT COUNT(*) FROM items")!, 1)
|
|
}
|
|
|
|
try source.backup(to: destination)
|
|
|
|
destination.inDatabase { db in
|
|
XCTAssertEqual(Int.fetchOne(db, "SELECT COUNT(*) FROM items")!, 1)
|
|
}
|
|
|
|
try source.inDatabase { db in
|
|
try db.execute("DROP TABLE items")
|
|
}
|
|
|
|
try source.backup(to: destination)
|
|
|
|
destination.inDatabase { db in
|
|
XCTAssertFalse(db.tableExists("items"))
|
|
}
|
|
}
|
|
}
|
|
}
|