Files
GRDB.swift/Tests/Public/Core/DatabaseQueue/DatabaseQueueTests.swift
T
swiftlyfalling 30bc7e4f6c Replace most uses of #if SQLITE_HAS_CODEC with the appropriate USING_BUILTIN_SQLITE or USING_SQLCIPHER defines.
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.
2016-05-30 18:19:45 -04:00

32 lines
1.1 KiB
Swift

import XCTest
#if USING_SQLCIPHER
import GRDBCipher
#elseif USING_CUSTOMSQLITE
import GRDBCustomSQLite
#else
import GRDB
#endif
class DatabaseQueueTests: GRDBTestCase {
func testInvalidFileFormat() {
assertNoError {
do {
let testBundle = NSBundle(forClass: self.dynamicType)
let path = testBundle.pathForResource("Betty", ofType: "jpeg")!
guard NSData(contentsOfFile: path) != nil else {
XCTFail("Missing file")
return
}
_ = try DatabaseQueue(path: path)
XCTFail("Expected error")
} catch let error as DatabaseError {
XCTAssertEqual(error.code, 26) // SQLITE_NOTADB
XCTAssertEqual(error.message!.lowercaseString, "file is encrypted or is not a database") // lowercaseString: accept multiple SQLite version
XCTAssertTrue(error.sql == nil)
XCTAssertEqual(error.description.lowercaseString, "sqlite error 26: file is encrypted or is not a database")
}
}
}
}