Files
GRDB.swift/Tests/Public/Core/DatabaseQueue/DatabaseQueueFileAttributesTests.swift
T
Gwendal Roué 88c284dbf1 Merge branch 'master' into Swift3bis
Conflicts:
	GRDB/Core/Database.swift
	GRDB/FetchRequest/QueryInterfaceRequest.swift
	GRDB/FetchRequest/SQLCollation.swift
	GRDB/FetchRequest/SQLFunction.swift
	GRDB/FetchRequest/SQLOperator.swift
	GRDB/FetchRequest/SQLSelectQuery.swift
	README.md
2016-06-02 20:47:04 +02:00

55 lines
1.9 KiB
Swift

import XCTest
#if USING_SQLCIPHER
import GRDBCipher
#elseif USING_CUSTOMSQLITE
import GRDBCustomSQLite
#else
import GRDB
#endif
class DatabaseQueueFileAttributesTests: GRDBTestCase {
func testDefaultFileAttributes() {
assertNoError {
let fm = NSFileManager.default()
let dbQueue = try makeDatabaseQueue()
var attributes = try fm.attributesOfItem(atPath: dbQueue.path)
XCTAssertFalse((attributes[NSFileExtensionHidden] as! NSNumber).boolValue)
}
}
func testExplicitFileAttributesOnExistingFile() {
assertNoError {
let fm = NSFileManager.default()
do {
let dbQueue = try makeDatabaseQueue()
let attributes = try fm.attributesOfItem(atPath: dbQueue.path)
XCTAssertFalse((attributes[NSFileExtensionHidden] as! NSNumber).boolValue)
}
do {
dbConfiguration.fileAttributes = [NSFileExtensionHidden: true]
let dbQueue = try makeDatabaseQueue()
let attributes = try fm.attributesOfItem(atPath: dbQueue.path)
XCTAssertTrue((attributes[NSFileExtensionHidden] as! NSNumber).boolValue)
}
}
}
func testExplicitFileAttributesOnNewFile() {
assertNoError {
let fm = NSFileManager.default()
dbConfiguration.fileAttributes = [NSFileExtensionHidden: true]
let dbQueue = try makeDatabaseQueue()
// TODO: this test is fragile: we have to wait until the database
// store has been notified of file creation.
NSThread.sleep(forTimeInterval: 0.1)
var attributes = try fm.attributesOfItem(atPath: dbQueue.path)
XCTAssertTrue((attributes[NSFileExtensionHidden] as! NSNumber).boolValue)
}
}
}