mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-10 22:45:55 +05:45
Continuing to look into [CSDK-517], I found this several times in the logs: > Purchases instance already set. Did you mean to configure two Purchases objects? In order to ensure that tests don't leave around unwanted state, I've turned this error into an assertion _only when running tests_, as well as fixed those cases. [CSDK-517]: https://revenuecats.atlassian.net/browse/CSDK-517?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
53 lines
1.2 KiB
Swift
53 lines
1.2 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// ProcessInfo+Extensions.swift
|
|
//
|
|
// Created by Nacho Soto on 11/29/22.
|
|
|
|
import Foundation
|
|
|
|
enum EnvironmentKey: String {
|
|
|
|
case XCTestConfigurationFile = "XCTestConfigurationFilePath"
|
|
case RCRunningTests = "RCRunningTests"
|
|
case RCRunningIntegrationTests = "RCRunningIntegrationTests"
|
|
|
|
}
|
|
|
|
extension ProcessInfo {
|
|
|
|
static subscript(key: EnvironmentKey) -> String? {
|
|
return Self.processInfo.environment[key.rawValue]
|
|
}
|
|
|
|
}
|
|
|
|
#if DEBUG
|
|
|
|
extension ProcessInfo {
|
|
|
|
static var isRunningUnitTests: Bool {
|
|
return self[.XCTestConfigurationFile] != nil
|
|
}
|
|
|
|
/// `true` when running unit or integration tests (configured in .xctestplan files).
|
|
static var isRunningRevenueCatTests: Bool {
|
|
return self[.RCRunningTests] == "1"
|
|
}
|
|
|
|
/// `true` when running integration tests (configured in .xctestplan files).
|
|
static var isRunningIntegrationTests: Bool {
|
|
return self[.RCRunningIntegrationTests] == "1"
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|