-
Notifications
You must be signed in to change notification settings - Fork 382
Increase simulated renewal time in some StoreKit integration tests #5382
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
Conversation
@RCGitBot please test |
📸 Snapshot Test705 unchanged
🛸 Powered by Emerge Tools |
// 'SKTestSession.TimeRate.monthlyRenewalEveryThirtySeconds' | ||
// However, we've found that their behavior is not equivalent since using `monthlyRenewalEveryThirtySeconds` | ||
// results in a crash in our tests. | ||
testSession.timeRate = .init(rawValue: 6)! // == .oneSecondIsOneDay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan of this, but using .oneSecondIsOneDay
directly creates a warning with a fix me
button that changes it to .monthlyRenewalEveryThirtySeconds
. And using .monthlyRenewalEveryThirtySeconds
always results in a crash in my local machine.
I think this is acceptable since we are in unit tests and it is clearly (?) documented with comments.
Lmk if you think otherwise!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could the rawValue
change between versions of iOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question. I don't think so, as it would mean breaking the API.
I wouldn't rely on this in the main code, but in unit tests I think it's fine (better this, with no warning and no fix me button that could lead to a crash.
For reference, this is the crash I'm getting locally when using .monthlyRenewalEveryThirtySeconds
instead of . oneSecondIsOneDay
.
https://forums.swift.org/t/sigabrt-freed-pointer-was-not-the-last-allocation-crash/78772
This reverts commit ece5003.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try it out!!
Motivation
We have some flaky StoreKit integration tests. This PR tries to make them less flaky.
Description
Some unit tests were randomly failing because the receipt posting would happen after the purchase expiration, which would cause the product entitlement become inactive.
This PR changes the
SKTestSession
'stimeRate
of some tests from.oneRenewalEveryTwoSeconds
to.oneSecondIsOneDay
. Because these affected tests simulate the purchase of a product with a 3-day trial, with this change, the first renewal time of the these tests changes from 2 seconds to 3 seconds, which should reduce their flakiness.