Skip to content

Commit

Permalink
SubscriberAttributesManagerIntegrationTests: fixed flaky failures (#…
Browse files Browse the repository at this point in the history
…2381)

Turns out we had already solved this race condition in #1492 that lead
to flaky failures,
but it was only in `BaseStoreKitIntegrationTests`. This moves it up to
`BaseBackendIntegrationTests` so that
`SubscriberAttributesManagerIntegrationTests` can use it too.

Fixes
https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/10501/workflows/cb6dbf22-cda8-4c41-875b-04b489992631/jobs/61135
  • Loading branch information
NachoSoto committed Mar 27, 2023
1 parent 9b1bc35 commit 3085cce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class BaseBackendIntegrationTests: XCTestCase {
self.clearReceiptIfExists()
self.configurePurchases()
self.verifyPurchasesDoesNotLeak()
try await self.waitForAnonymousUser()
}

}
Expand Down Expand Up @@ -115,6 +116,14 @@ private extension BaseBackendIntegrationTests {
}
}

func waitForAnonymousUser() async throws {
// SDK initialization begins with an initial request to offerings,
// which results in a get-create of the initial anonymous user.
// To avoid race conditions with when this request finishes and make all tests deterministic
// this waits for that request to finish.
_ = try await Purchases.shared.offerings()
}

private var dangerousSettings: DangerousSettings {
return .init(autoSyncPurchases: true,
internalSettings: .init(enableReceiptFetchRetry: true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ class BaseStoreKitIntegrationTests: BaseBackendIntegrationTests {
// (and transactions has been cleared), to avoid the SDK posting receipts from
// a previous test.
try await super.setUp()

// SDK initialization begins with an initial request to offerings
// Which results in a get-create of the initial anonymous user.
// To avoid race conditions with when this request finishes and make all tests deterministic
// this waits for that request to finish.
_ = try await Purchases.shared.offerings()
}

override func tearDown() {
Expand Down

0 comments on commit 3085cce

Please sign in to comment.