Skip to content

PurchasesOrchestrator: don't listen for StoreKit 2 transactions if it's disabled#1593

Merged
NachoSoto merged 1 commit into
mainfrom
lazy-var-workaround
May 26, 2022
Merged

PurchasesOrchestrator: don't listen for StoreKit 2 transactions if it's disabled#1593
NachoSoto merged 1 commit into
mainfrom
lazy-var-workaround

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

I tried adding tests for this, but because the listener is created internally, there is no time to override it with the mock before verifying if listenForTransactions is called.

Will at least prevent #1528 if SK2 is disabled.

@NachoSoto NachoSoto requested a review from a team May 20, 2022 22:39

if #available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) {
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *),
systemInfo.storeKit2Setting == .enabledForCompatibleDevices {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏼

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like we should have an accompanying test for this, so we don't inadvertently break it in the future. It can be done as a separate PR

@aboedo aboedo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved, but could you add a test for it?


if #available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) {
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *),
systemInfo.storeKit2Setting == .enabledForCompatibleDevices {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like we should have an accompanying test for this, so we don't inadvertently break it in the future. It can be done as a separate PR

@NachoSoto

Copy link
Copy Markdown
Contributor Author

See the description:

I tried adding tests for this, but because the listener is created internally, there is no time to override it with the mock before verifying if listenForTransactions is called.

I couldn't think of a way to add a test for it.

@aboedo

aboedo commented May 26, 2022

Copy link
Copy Markdown
Member

@NachoSoto I see, good catch. Good to go then!
Once we have #1596 merged we should be able to inject the property and then make tests for this, right?

…it's disabled

I tried adding tests for this, but because the listener is created internally, there is no time to override it with the mock before verifying if `listenForTransactions` is called.
@NachoSoto

Copy link
Copy Markdown
Contributor Author

Once we have #1596 merged we should be able to inject the property and then make tests for this,

The rabbit hole goes deep and deep:

  • We need 2 constructors of PurchasesOrchestrator, one with an @available annotation
  • Purchases needs to do if #available to decide which constructor to call

Here's a proposed solution: #1618

It adds a fair amount of complexity, but I guess it's important to test this.

@NachoSoto

Copy link
Copy Markdown
Contributor Author

I'll merge this for now, maybe we can have it out in the release.

@NachoSoto NachoSoto merged commit 7a3cf51 into main May 26, 2022
@NachoSoto NachoSoto deleted the lazy-var-workaround branch May 26, 2022 18:16
@NachoSoto NachoSoto mentioned this pull request May 26, 2022
NachoSoto added a commit that referenced this pull request May 26, 2022
NachoSoto added a commit that referenced this pull request May 26, 2022
…ns` only if SK2 is enabled (#1618)

Follow up to #1593 and #1596.

This adds a fair amount of complexity, but I guess it's important to test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants