mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 19:45:22 +00:00
Skip CoreLocation setup in test environments
Add isRunningTests check to LocationStateManager to skip CoreLocation delegate and permission initialization in test/CI environments. This prevents potential blocking or unexpected behavior when tests access LocationStateManager.shared.
This commit is contained in:
@@ -59,11 +59,28 @@ final class LocationStateManager: NSObject, CLLocationManagerDelegate, Observabl
|
|||||||
private var resolvingNames: Set<String> = []
|
private var resolvingNames: Set<String> = []
|
||||||
private let storage: UserDefaults
|
private let storage: UserDefaults
|
||||||
|
|
||||||
|
/// Returns true if running in test environment
|
||||||
|
private static var isRunningTests: Bool {
|
||||||
|
let env = ProcessInfo.processInfo.environment
|
||||||
|
return NSClassFromString("XCTestCase") != nil ||
|
||||||
|
env["XCTestConfigurationFilePath"] != nil ||
|
||||||
|
env["XCTestBundlePath"] != nil ||
|
||||||
|
env["GITHUB_ACTIONS"] != nil ||
|
||||||
|
env["CI"] != nil
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Initialization
|
// MARK: - Initialization
|
||||||
|
|
||||||
private override init() {
|
private override init() {
|
||||||
self.storage = .standard
|
self.storage = .standard
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
|
// Skip CoreLocation setup in test environments
|
||||||
|
guard !Self.isRunningTests else {
|
||||||
|
loadPersistedState()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cl.delegate = self
|
cl.delegate = self
|
||||||
cl.desiredAccuracy = kCLLocationAccuracyHundredMeters
|
cl.desiredAccuracy = kCLLocationAccuracyHundredMeters
|
||||||
cl.distanceFilter = TransportConfig.locationDistanceFilterMeters
|
cl.distanceFilter = TransportConfig.locationDistanceFilterMeters
|
||||||
|
|||||||
Reference in New Issue
Block a user