Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubscriberAttributesManagerIntegrationTests: fixed flaky failures #2381

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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