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

SKError, StoreKitError, and Product.PurchaseError conform to ErrorCodeConvertible + tests #1473

Merged
merged 1 commit into from
Apr 12, 2022

Conversation

NachoSoto
Copy link
Contributor

@NachoSoto NachoSoto commented Apr 8, 2022

Follow up to #1437.
Fixes CF-323

@NachoSoto NachoSoto requested a review from a team April 8, 2022 18:03
Comment on lines +94 to +113
func testCurrentlySubscribedError() throws {
let error = try XCTUnwrap(
NSError(
domain: SKErrorDomain,
code: SKError.unknown.rawValue,
userInfo: [
NSUnderlyingErrorKey: NSError(
domain: "ASDServerErrorDomain",
code: 3532,
userInfo: [:]
)
]
) as? SKError
)

verifyPurchasesError(error,
expectedCode: .productAlreadyPurchasedError,
underlyingError: error)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are much better to test this way instead of in PurchasesTests. Though I left the original tests too.

@@ -15,9 +15,9 @@ import StoreKit

/// - SeeAlso: SKError+Extensions
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
extension StoreKitError {
extension StoreKitError: ErrorCodeConvertible {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now all our errors conform to this 🎉

@NachoSoto NachoSoto changed the title SKError, StoreKitError, and Product.PurchaseError conform to ErrorCodeConvertible and added tests SKError, StoreKitError, and Product.PurchaseError conform to ErrorCodeConvertible + tests Apr 8, 2022
@NachoSoto NachoSoto force-pushed the storekit-error-conversion-tests branch from d65d66e to 67c8f43 Compare April 8, 2022 18:15
@NachoSoto NachoSoto force-pushed the storekit-error-conversion-tests branch from 67c8f43 to 3e4cb4c Compare April 8, 2022 21:39
@NachoSoto NachoSoto force-pushed the storekit-error-conversion-tests branch from 3e4cb4c to d124750 Compare April 8, 2022 22:52
underlyingError: error)
}

func testPaymentSheetCancelledError() throws {
Copy link
Contributor

Choose a reason for hiding this comment

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

YESSssssss

) as? SKError
)

verifyPurchasesError(error,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is so good that we have tests for this. I'm loving the new errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'm using this new helper in all of these which makes it very simple :)
Screen Shot 2022-04-11 at 10 25 35

Copy link
Contributor

@taquitos taquitos left a comment

Choose a reason for hiding this comment

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

🕺🐐

@NachoSoto NachoSoto force-pushed the storekit-error-conversion-tests branch from d124750 to 1930eb0 Compare April 12, 2022 19:46
Base automatically changed from http-error to wip-decodable-3-rebased April 12, 2022 20:58
@NachoSoto NachoSoto force-pushed the storekit-error-conversion-tests branch from 1930eb0 to 2d129d0 Compare April 12, 2022 21:04
Base automatically changed from wip-decodable-3-rebased to main April 12, 2022 22:11
…rrorCodeConvertible` and added tests

Follow up to #1437.
Fixes [CF-323]
@NachoSoto NachoSoto force-pushed the storekit-error-conversion-tests branch from 2d129d0 to 59422da Compare April 12, 2022 22:12
@NachoSoto NachoSoto merged commit cf0a1bd into main Apr 12, 2022
@NachoSoto NachoSoto deleted the storekit-error-conversion-tests branch April 12, 2022 22:13
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