Skip to content

Purchases.restoreLogHandler#2699

Merged
NachoSoto merged 2 commits into
mainfrom
purchases-log-handler
Jun 26, 2023
Merged

Purchases.restoreLogHandler#2699
NachoSoto merged 2 commits into
mainfrom
purchases-log-handler

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

Purchases.verboseLogHandler changed in #2608 with the introduction of a new internalLogHandler.
Restoring the log handler doing Purchases.verboseLogHandler = Purchases.verboseLogHandler now loses the message category.

We didn't have test coverage for Purchases.logHandler either which this adds as well.

This also fixes tests in RevenueCat/purchases-hybrid-common#435

`Purchases.verboseLogHandler` changed in #2608 with the introduction of a new `internalLogHandler`.
Restoring the log handler doing `Purchases.verboseLogHandler = Purchases.verboseLogHandler` now loses the message category.

We didn't have test coverage for `Purchases.logHandler` either which this adds as well.

This also fixes tests in RevenueCat/purchases-hybrid-common#435
@NachoSoto NachoSoto added the test label Jun 23, 2023
@NachoSoto NachoSoto requested a review from a team June 23, 2023 16:32
@codecov

codecov Bot commented Jun 23, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2699 (6ae67a8) into main (984b231) will increase coverage by 0.12%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2699      +/-   ##
==========================================
+ Coverage   86.58%   86.71%   +0.12%     
==========================================
  Files         211      211              
  Lines       14987    14990       +3     
==========================================
+ Hits        12976    12998      +22     
+ Misses       2011     1992      -19     
Impacted Files Coverage Δ
Sources/Purchasing/Purchases/Purchases.swift 76.15% <100.00%> (+1.30%) ⬆️

... and 6 files with indirect coverage changes

deinit { Self.sharedHandler.remove(observer: self) }

/// If a test overrides `Purchases.verboseLogHandler` or `Logger.internalLogHandler`
/// this needs to be called to re-install the test handler.

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.

Is it worth doing this before every test? Just so we don't forget in the future

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That would break with TestLogHandler because it gets installed only once.

@NachoSoto NachoSoto merged commit d9b1192 into main Jun 26, 2023
@NachoSoto NachoSoto deleted the purchases-log-handler branch June 26, 2023 15:57
NachoSoto added a commit that referenced this pull request Jun 30, 2023
**This is an automatic release.**

### New Features
* New `TestStoreProduct` for creating mock `StoreProduct`s and
`Offering`s (#2711) via NachoSoto (@NachoSoto)

✨ With this new API you can now create fake products for unit tests and
SwiftUI previews! 🎉
#### Example:
```swift
let product = TestStoreProduct(
    localizedTitle: "PRO monthly",
    price: 3.99,
    localizedPriceString: "$3.99",
    productIdentifier: "com.revenuecat.product",
    productType: .autoRenewableSubscription,
    localizedDescription: "Description",
    subscriptionGroupIdentifier: "group",
    subscriptionPeriod: .init(value: 1, unit: .month)
)
let offering = Offering(
    identifier: "offering",
    serverDescription: "Main offering",
    metadata: [:],
    availablePackages: [
        .init(
            identifier: "monthly",
            packageType: .monthly,
            storeProduct: product.toStoreProduct(),
            offeringIdentifier: offering
        )
    ]
)
```

### Dependency Updates
* Bump fastlane-plugin-revenuecat_internal from `13773d2` to `b2108fb`
(#2706) via dependabot[bot] (@dependabot[bot])
### Other Changes
* `VerificationResult: CustomDebugStringConvertible` (#2739) via
NachoSoto (@NachoSoto)
* Refactor: simplified `PurchasesOrchestrator.syncPurchases` (#2731) via
NachoSoto (@NachoSoto)
* `Trusted Entitlements`: add integration tests to verify `CustomerInfo`
cache invalidation (#2730) via NachoSoto (@NachoSoto)
* `SystemInfo.identifierForVendor`: add tests (#2732) via NachoSoto
(@NachoSoto)
* `Tests`: disabled `iOS 11.x` tests to fix `Xcode 15` tests (#2720) via
NachoSoto (@NachoSoto)
* `DebugViewSwiftUITests`: create separate snapshots for each OS version
(#2721) via NachoSoto (@NachoSoto)
* `Integration Tests`: fix clearing `UserDefaults` before each test
(#2719) via NachoSoto (@NachoSoto)
* Remove unused `Signing.loadPublicKey(with:)` (#2714) via NachoSoto
(@NachoSoto)
* Add `UInt32(littleEndian32Bits:)` and `UInt32.littleEndianData`
(#2713) via NachoSoto (@NachoSoto)
* `TimingUtil`: added synchronous API (#2716) via NachoSoto (@NachoSoto)
* `XCFramework`: sign archive for `Xcode 15` (#2709) via NachoSoto
(@NachoSoto)
* `CI`: removed `carthage_archive` from `release` lane (#2710) via
NachoSoto (@NachoSoto)
* `PriceFormatterProvider.priceFormatterForSK2`: enable on all versions
(#2712) via NachoSoto (@NachoSoto)
* `xrOS`: add support for `debugRevenueCatOverlay` (#2702) via NachoSoto
(@NachoSoto)
* Refactor method to get product ID including plan ID in android
purchases (#2708) via Toni Rico (@tonidero)
* `Purchases.restoreLogHandler` (#2699) via NachoSoto (@NachoSoto)
* Remove alpha from purchase tester icon to upload to testflight (#2705)
via Toni Rico (@tonidero)

---------

Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
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.

2 participants