mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
Added `rc_receipt_url` and `rc_receipt_file_exists`. This is useful when debugging issues like #2558. This goes from this: > [Purchases] - ERROR: 💰 Product purchase for 'rc_1099_1w' failed with error: Error Domain=RevenueCat.ErrorCode Code=9 "The receipt is missing." UserInfo={NSLocalizedDescription=The receipt is missing., readable_error_code=MISSING_RECEIPT_FILE, source_function=handlePurchasedTransaction(_:data:completion:), source_file=RevenueCat/TransactionPoster.swift:96} To this: > [Purchases] - ERROR: 💰 Product purchase for 'rc_1099_1w' failed with error: Error Domain=RevenueCat.ErrorCode Code=9 "The receipt is missing." UserInfo={NSLocalizedDescription=The receipt is missing., readable_error_code=MISSING_RECEIPT_FILE, source_function=handlePurchasedTransaction(_:data:completion:), rc_receipt_url=file:///.../Build/Products/Debug/...app/Contents/_MASReceipt/receipt, rc_receipt_file_exists=true, source_file=RevenueCat/TransactionPoster.swift:96} In this case, we can see the file does exist, so it must be empty.
72 lines
2.3 KiB
Swift
72 lines
2.3 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// BackendErrorTests.swift
|
|
//
|
|
// Created by Nacho Soto on 4/7/22.
|
|
|
|
import Nimble
|
|
@testable import RevenueCat
|
|
import XCTest
|
|
|
|
class BackendErrorTests: BaseErrorTests {
|
|
|
|
func testMissingAppUserID() {
|
|
let error: BackendError = .missingAppUserID()
|
|
|
|
verifyPurchasesError(error, expectedCode: .invalidAppUserIdError)
|
|
}
|
|
|
|
func testEmptySubscriberAttributes() {
|
|
let error: BackendError = .emptySubscriberAttributes()
|
|
|
|
verifyPurchasesError(error, expectedCode: .emptySubscriberAttributes)
|
|
}
|
|
|
|
func testMissingReceiptFile() {
|
|
let error: BackendError = .missingReceiptFile(nil)
|
|
|
|
verifyPurchasesError(error, expectedCode: .missingReceiptFileError)
|
|
}
|
|
|
|
func testMissingTransactionProductIdentifier() {
|
|
let error: BackendError = .missingTransactionProductIdentifier()
|
|
|
|
verifyPurchasesError(error, expectedCode: .unknownError)
|
|
}
|
|
|
|
func testUnexpectedBackendResponse() {
|
|
let underlyingError: BackendError.UnexpectedBackendResponseError = .customerInfoNil
|
|
let error: BackendError = .unexpectedBackendResponse(underlyingError,
|
|
extraContext: "context")
|
|
|
|
verifyPurchasesError(error,
|
|
expectedCode: .unexpectedBackendResponseError,
|
|
underlyingError: underlyingError as NSError)
|
|
}
|
|
|
|
func testSubscriptionNotFoundErrorsArentSuccessfullySynced() {
|
|
// See https://github.com/RevenueCat/purchases-ios/pull/1479
|
|
// This test ensures that if that race condition does happen
|
|
// at least the attributes won't be marked as synced
|
|
|
|
let response = ErrorResponse(
|
|
code: .subscriptionNotFoundForCustomer,
|
|
originalCode: BackendErrorCode.subscriptionNotFoundForCustomer.rawValue,
|
|
message: "Subscription not found for subscriber",
|
|
attributeErrors: [:]
|
|
)
|
|
|
|
let error: BackendError = .networkError(.errorResponse(response, .notFoundError))
|
|
|
|
expect(error.successfullySynced) == false
|
|
}
|
|
|
|
}
|