TM-SGNL-iOS/SignalServiceKit/tests/SSKBaseTest.swift
TeleMessage developers dde0620daf initial commit
2025-05-03 12:28:28 -07:00

36 lines
1.1 KiB
Swift

//
// Copyright 2018 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
public import XCTest
@testable public import SignalServiceKit
import CocoaLumberjack
public class SSKBaseTest: XCTestCase {
public override func setUp() {
DDLog.add(DDTTYLogger.sharedInstance!)
MockSSKEnvironment.activate()
}
public override func tearDown() {
MockSSKEnvironment.flushAndWait()
super.tearDown()
}
public func read(_ block: (SDSAnyReadTransaction) -> Void) {
return SSKEnvironment.shared.databaseStorageRef.read(block: block)
}
public func write<T>(_ block: (SDSAnyWriteTransaction) -> T) -> T {
return SSKEnvironment.shared.databaseStorageRef.write(block: block)
}
public func write<T>(_ block: (SDSAnyWriteTransaction) throws -> T) rethrows -> T {
try SSKEnvironment.shared.databaseStorageRef.write(block: block)
}
public func asyncWrite(_ block: @escaping (SDSAnyWriteTransaction) -> Void) {
return SSKEnvironment.shared.databaseStorageRef.asyncWrite(block: block)
}
}