mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
46 lines
1.6 KiB
Swift
46 lines
1.6 KiB
Swift
import XCTest
|
|
import GRDB
|
|
|
|
class DatabaseQueueFileAttributesTests: GRDBTestCase {
|
|
|
|
func testDefaultFileAttributes() {
|
|
assertNoError {
|
|
let fm = NSFileManager.defaultManager()
|
|
|
|
_ = dbQueue
|
|
var attributes = try fm.attributesOfItemAtPath(dbQueuePath)
|
|
XCTAssertFalse((attributes[NSFileExtensionHidden] as! NSNumber).boolValue)
|
|
}
|
|
}
|
|
|
|
func testExplicitFileAttributesOnExistingFile() {
|
|
assertNoError {
|
|
let fm = NSFileManager.defaultManager()
|
|
|
|
_ = dbQueue
|
|
dbQueue = nil
|
|
var attributes = try fm.attributesOfItemAtPath(dbQueuePath)
|
|
XCTAssertFalse((attributes[NSFileExtensionHidden] as! NSNumber).boolValue)
|
|
|
|
dbConfiguration.fileAttributes = [NSFileExtensionHidden: true]
|
|
_ = dbQueue
|
|
attributes = try fm.attributesOfItemAtPath(dbQueuePath)
|
|
XCTAssertTrue((attributes[NSFileExtensionHidden] as! NSNumber).boolValue)
|
|
}
|
|
}
|
|
|
|
func testExplicitFileAttributesOnNewFile() {
|
|
assertNoError {
|
|
let fm = NSFileManager.defaultManager()
|
|
|
|
dbConfiguration.fileAttributes = [NSFileExtensionHidden: true]
|
|
_ = dbQueue
|
|
// TODO: this test is fragile: we have to wait until the database
|
|
// store has been notified of file creation.
|
|
NSThread.sleepForTimeInterval(0.1)
|
|
var attributes = try fm.attributesOfItemAtPath(dbQueuePath)
|
|
XCTAssertTrue((attributes[NSFileExtensionHidden] as! NSNumber).boolValue)
|
|
}
|
|
}
|
|
}
|