IntegrationTests: replaced Purchases.shared with a throwing property#2867
Merged
Conversation
NachoSoto
commented
Jul 24, 2023
Comment on lines
18
to
22
Contributor
Author
There was a problem hiding this comment.
This was missing too.
…perty This is a similar change to #2532. I noticed yet another source of crashes in our integration tests. This is what the result was: ``` failed - Message 'Finishing transaction' should not have been logged expected to not find object in collection that satisfies predicate ``` That came from this code: ```swift self.logger.verifyMessageWasNotLogged("Finishing transaction") let info1 = try await Purchases.shared.customerInfo() ``` After that assertion failure, `XCTest` continued execusion, while it had already tear down `Purchases`, which lead to this crash: ``` Thread 0 Crashed: 0 libswiftCore.dylib 0x103b84e81 _assertionFailure(_:_:file:line:flags:) + 353 1 RevenueCat 0x1332516d0 static Purchases.shared.getter + 352 (Purchases.swift:65) 2 BackendIntegrationTests 0x130f7048a OfflineStoreKit1IntegrationTests.testPurchaseWhileServerIsDownPostsReceiptWhenForegroundingApp() + 362 (OfflineStoreKitIntegrationTests.swift:289) 3 BackendIntegrationTests 0x130f75ee1 @objc closure #1 in OfflineStoreKit1IntegrationTests.testPurchaseWhileServerIsDownPostsReceiptWhenForegroundingApp() + 1 4 BackendIntegrationTests 0x130f77d91 partial apply for @objc closure #1 in OfflineStoreKit1IntegrationTests.testPurchaseWhileServerIsDownPostsReceiptWhenForegroundingApp() + 1 ``` To prevent this, instead of using `Purchases.shared` this replaces that with a throwing `self.purchases`. Just like we don't use force-unwraps in tests and instead use `XCTUwnrap`, this now will fail the test instead of crashing it.
a513e03 to
f662094
Compare
tonidero
approved these changes
Jul 24, 2023
NachoSoto
added a commit
that referenced
this pull request
Jul 26, 2023
**This is an automatic release.** _This release is compatible with Xcode 15 beta 5 and visionOS beta 2_ ### Bugfixes * `xrOS`: fixed `SubscriptionStoreView` for visionOS beta 2 (#2884) via Josh Holtz (@joshdholtz) ### Performance Improvements * `Perf`: update `CustomerInfo` cache before anything else (#2865) via NachoSoto (@NachoSoto) ### Other Changes * `SimpleApp`: added support for localization (#2880) via NachoSoto (@NachoSoto) * `TestStoreProduct`: made available on release builds (#2861) via NachoSoto (@NachoSoto) * `Tests`: increased default logger capacity (#2870) via NachoSoto (@NachoSoto) * `CustomEntitlementComputation`: removed `invalidateCustomerInfoCache` (#2866) via NachoSoto (@NachoSoto) * `SimpleApp`: updates for TestFlight compatibility (#2862) via NachoSoto (@NachoSoto) * `BasePurchasesTests`: consolidate to only initialize one `DeviceCache` (#2863) via NachoSoto (@NachoSoto) * `Codable`: debug log entire JSON when decoding fails (#2864) via NachoSoto (@NachoSoto) * `IntegrationTests`: replaced `Purchases.shared` with a `throw`ing property (#2867) via NachoSoto (@NachoSoto) * `NetworkError`: 2 new tests to ensure underlying error is included in description (#2843) via NachoSoto (@NachoSoto) * Add SPM `Package.resolved` for Xcode Cloud (#2844) via NachoSoto (@NachoSoto) * `CustomEntitlementComputation`: added integration test for cancellations (#2849) via NachoSoto (@NachoSoto) * `CustomEntitlementComputation`: removed `syncPurchases`/`restorePurchases` (#2854) via NachoSoto (@NachoSoto) --------- Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a similar change to #2532.
I noticed yet another source of crashes in our integration tests.
This is what the result was:
That came from this code:
After that assertion failure,
XCTestcontinued execution, while it had already tear downPurchases, which lead to this crash:To prevent this, instead of using
Purchases.sharedthis replaces that with a throwingself.purchases.Just like we don't use force-unwraps in tests and instead use
XCTUwnrap, this now will fail the test instead of crashing it.