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

Make use of PurchasesType inside PurchasesDelegate to allow mocking #3039

Open
AvdLee opened this issue Aug 17, 2023 · 3 comments
Open

Make use of PurchasesType inside PurchasesDelegate to allow mocking #3039

AvdLee opened this issue Aug 17, 2023 · 3 comments
Labels
breaking Changes that are breaking enhancement

Comments

@AvdLee
Copy link

AvdLee commented Aug 17, 2023

Right now, delegate methods are defined using the strongly typed Purchases. Therefore, we have to call Purchases.configure in case we want to write tests for methods like:

func purchases(
        _ purchases: Purchases,
        readyForPromotedProduct product: StoreProduct,
        purchase startPurchase: @escaping StartPurchaseBlock
    )

Instead, if the above delegate method would've been defined as:

func purchases(
        _ purchases: PurchasesType,
        readyForPromotedProduct product: StoreProduct,
        purchase startPurchase: @escaping StartPurchaseBlock
    )

We could create a mocked PurchasesType to use in our tests. I can see this as another great improvement similar to the TestProducts release.

@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@NachoSoto
Copy link
Contributor

Thanks for the suggestion @AvdLee. It would indeed make it a lot easier.

Unfortunately PurchasesType was added after the initial 4.0 release, and there is no way to make this change now in a backwards compatible way, which would require a major release:
Screenshot 2023-08-17 at 10 36 32

We also can't even provide an @availability annotation with renamed:
Screenshot 2023-08-17 at 10 37 00

We'll leave this issue open for our next upcoming major release though, so we can tackle this at the same time as when we drop support for iOS 11.

@NachoSoto NachoSoto added the breaking Changes that are breaking label Aug 17, 2023
@BasThomas
Copy link
Contributor

Just wondering if this is something you're considering tackling for the upcoming 5.0 release? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Changes that are breaking enhancement
Projects
None yet
Development

No branches or pull requests

4 participants