forked from ChatSecure/ChatSecure-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOTRTestDatabase.swift
38 lines (33 loc) · 1.12 KB
/
OTRTestDatabase.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// OTRTestDatabase.swift
// ChatSecure
//
// Created by David Chiles on 10/7/16.
// Copyright © 2016 Chris Ballinger. All rights reserved.
//
import UIKit
@testable import ChatSecureCore
class OTRTestDatabaseManager:OTRDatabaseManager {
override class func yapDatabaseDirectory() -> String {
return NSTemporaryDirectory()
}
class func setupDatabaseWithName(name:String) -> OTRDatabaseManager {
let datatabseManager = OTRTestDatabaseManager()
datatabseManager.setDatabasePassphrase("password", remember: false, error: nil)
datatabseManager.setupDatabaseWithName(name, withMediaStorage: false)
return datatabseManager
}
}
extension NSFileManager {
func clearDirectory(directory:String) {
// Clear any Files in directy
do {
let contents = try self.contentsOfDirectoryAtPath(directory)
try contents.forEach { (path) in
let fullPath = (directory as NSString).stringByAppendingPathComponent(path)
try NSFileManager().removeItemAtPath(fullPath)
}
} catch {
}
}
}