mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
This modifies `BaseStoreKitIntegrationTests.printReceipt` to also log `StoreKit 2` transactions which can be used to debug failures of `OfflineStoreKitIntegrationTests`. `PurchasedProductsFetcher` also logs how many `currentEntitlements` it found since failures are coming from there.
93 lines
2.8 KiB
Swift
93 lines
2.8 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
|
|
//
|
|
// Messages.swift
|
|
//
|
|
// Created by Nacho Soto on 6/13/23.
|
|
|
|
import Foundation
|
|
|
|
#if ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION
|
|
@testable import RevenueCat_CustomEntitlementComputation
|
|
#else
|
|
@testable import RevenueCat
|
|
#endif
|
|
|
|
import StoreKit
|
|
|
|
// swiftlint:disable identifier_name
|
|
|
|
enum TestMessage: LogMessage {
|
|
|
|
case expiring_subscription(productID: String)
|
|
case expire_subscription_failed(Error)
|
|
case finished_waiting_for_expiration
|
|
case sleeping_to_force_expiration(seconds: Int)
|
|
|
|
case resetting_purchases_singleton
|
|
case removing_receipt(URL)
|
|
case error_removing_url(URL, Error)
|
|
case receipt_content(String)
|
|
case current_entitlements([StoreKit.VerificationResult<StoreKit.Transaction>])
|
|
case unfinished_transactions([StoreKit.VerificationResult<StoreKit.Transaction>])
|
|
case unable_parse_receipt_without_sdk
|
|
case error_parsing_receipt(Error)
|
|
|
|
}
|
|
|
|
extension TestMessage {
|
|
|
|
var description: String {
|
|
switch self {
|
|
case let .expiring_subscription(productID):
|
|
return "Expiring subscription for product '\(productID)'"
|
|
|
|
case let .expire_subscription_failed(error):
|
|
return """
|
|
Failed testSession.expireSubscription, this is probably an Xcode bug.
|
|
Test will now wait for expiration instead of triggering it.
|
|
Error: \(error.localizedDescription)
|
|
"""
|
|
|
|
case .finished_waiting_for_expiration:
|
|
return "Done waiting for subscription expiration, continuing test."
|
|
|
|
case let .sleeping_to_force_expiration(seconds):
|
|
return "Sleeping for \(seconds) seconds to force expiration"
|
|
|
|
case .resetting_purchases_singleton:
|
|
return "Resetting Purchases.shared"
|
|
|
|
case let .removing_receipt(url):
|
|
return "Removing receipt from url: \(url)"
|
|
|
|
case let .error_removing_url(url, error):
|
|
return "Error attempting to remove receipt URL '\(url)': \(error)"
|
|
|
|
case let .receipt_content(receipt):
|
|
return "Receipt content:\n\(receipt)"
|
|
|
|
case let .current_entitlements(transactions):
|
|
return "Current entitlements:\n\(transactions)"
|
|
|
|
case let .unfinished_transactions(transactions):
|
|
return "Unfinished transactions:\n\(transactions)"
|
|
|
|
case .unable_parse_receipt_without_sdk:
|
|
return "Can't print receipt when purchases isn't configured"
|
|
|
|
case let .error_parsing_receipt(error):
|
|
return "Error parsing local receipt: \(error)"
|
|
}
|
|
}
|
|
|
|
var category: String { return "IntegrationTests" }
|
|
|
|
}
|