Files
purchases-ios/Sources/FoundationExtensions/ProcessInfo+Extensions.swift
T
NachoSoto 599cfda5fb enableAdServicesAttributionTokenCollection: added integration test (#2551)
Because `AAAttribution.attributionToken()` isn't available on
simulators, we currently had no coverage for this entire part of the
codebase.
By mocking the token (on simulator + debug + integration tests only), we
can verify posting to the server works correctly.

As a follow-up, we can also verify that posting it as part of the
receipt with #2549 works correctly as well.
2023-05-26 07:18:51 -07:00

58 lines
1.4 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
#if DEBUG
enum EnvironmentKey: String {
case XCTestConfigurationFile = "XCTestConfigurationFilePath"
case RCRunningTests = "RCRunningTests"
case RCRunningIntegrationTests = "RCRunningIntegrationTests"
case RCMockAdServicesToken = "RCMockAdServicesToken"
}
extension ProcessInfo {
static subscript(key: EnvironmentKey) -> String? {
return Self.processInfo.environment[key.rawValue]
}
}
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"
}
static var mockAdServicesToken: String? {
return self[.RCMockAdServicesToken]?.notEmptyOrWhitespaces
}
}
#endif