You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import YapDatabase
|
|
|
|
|
|
|
|
// FIXME: Turn this into a protocol to make mocking possible
|
|
|
|
final class TestTransaction: YapDatabaseReadWriteTransaction, Mockable {
|
|
|
|
// MARK: - Mockable
|
|
|
|
|
|
|
|
enum DataKey: Hashable {
|
|
|
|
case objectForKey
|
|
|
|
}
|
|
|
|
|
|
|
|
typealias Key = DataKey
|
|
|
|
|
|
|
|
var mockData: [DataKey: Any] = [:]
|
|
|
|
|
|
|
|
// MARK: - YapDatabaseReadWriteTransaction
|
|
|
|
|
|
|
|
override func object(forKey key: String, inCollection collection: String?) -> Any? {
|
|
|
|
if let dictionary: [String: Any] = mockData[.objectForKey] as? [String: Any] {
|
|
|
|
return dictionary[key]
|
|
|
|
}
|
|
|
|
|
|
|
|
return mockData[.objectForKey]
|
|
|
|
}
|
|
|
|
|
|
|
|
override func addCompletionQueue(_ completionQueue: DispatchQueue?, completionBlock: @escaping () -> Void) {
|
|
|
|
completionBlock()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension TestTransaction: Mocked {
|
|
|
|
static var mockValue: TestTransaction = TestTransaction()
|
|
|
|
}
|