-
Notifications
You must be signed in to change notification settings - Fork 295
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
HTTPClientTests
: fixed failing test with missing assertions
#2262
Conversation
} | ||
} | ||
|
||
expect(result).to(beSuccess()) | ||
expect(requests.value) == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
73abde2
to
65bd937
Compare
HTTPClientTests
: failing test to expose race conditionHTTPClientTests
: fixed failing test with missing assertions
Codecov Report
@@ Coverage Diff @@
## main #2262 +/- ##
==========================================
+ Coverage 85.96% 85.98% +0.02%
==========================================
Files 183 183
Lines 12119 12119
==========================================
+ Hits 10418 10421 +3
+ Misses 1701 1698 -3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
great catch! |
Updated. |
Similarly to #2262, test execution ordering was leading to [flaky code coverage results](https://app.codecov.io/gh/RevenueCat/purchases-ios/pull/2262) with this. Because we didn't have any test coverage, only if some other test changed the `Storefront`, this test was calling the delegate code. This adds explicit test coverage using a `MockAsyncSequence`. - Added `StorefrontType` to `StoreKit2StorefrontListenerDelegate` method - `Storefront` initializers are no longer `Optional` `init?` - Simplified `StoreKit2StorefrontListenerTests` by moving `AvailabilityChecks` to `setUp`
Similarly to #2262, test execution ordering was leading to [flaky code coverage results](https://app.codecov.io/gh/RevenueCat/purchases-ios/pull/2262) with this. Because we didn't have any test coverage, only if some other test changed the `Storefront`, this test was calling the delegate code. This adds explicit test coverage using a `MockAsyncSequence`. - Added `StorefrontType` to `StoreKit2StorefrontListenerDelegate` method - `Storefront` initializers are no longer `Optional` `init?` - Simplified `StoreKit2StorefrontListenerTests` by moving `AvailabilityChecks` to `setUp`
…#2265) Similarly to #2262, test execution ordering was leading to [flaky code coverage results](https://app.codecov.io/gh/RevenueCat/purchases-ios/pull/2262) with this. ![Screenshot 2023-02-06 at 10 48 45](https://user-images.githubusercontent.com/685609/217058841-33a07262-7959-4732-9706-7426d8f4efb7.png) Because we didn't have any test coverage, only if some other test changed the `Storefront`, this test was calling the delegate code. This adds explicit test coverage using a `MockAsyncSequence`. ### Other changes: - Added `StorefrontType` to `StoreKit2StorefrontListenerDelegate` method - `Storefront` initializers are no longer `Optional` `init?` - Simplified `StoreKit2StorefrontListenerTests` by moving `AvailabilityChecks` to `setUp`
**This is an automatic release.** ### Dependency Updates * Bump fastlane-plugin-revenuecat_internal from `738f255` to `9255366` (#2264) via dependabot[bot] (@dependabot[bot]) * Update `Gemfile.lock` (#2254) via Cesar de la Vega (@vegaro) ### Other Changes * `HTTPClient`: added support for sending `X-Nonce` (#2214) via NachoSoto (@NachoSoto) * `Configuration`: added (`internal` for now) API to load public key (#2215) via NachoSoto (@NachoSoto) * Replaced `Any` uses for workaround with `Box` (#2250) via NachoSoto (@NachoSoto) * `HTTPClientTests`: fixed failing test with missing assertions (#2262) via NachoSoto (@NachoSoto) * `HTTPClientTests`: refactored tests to use `waitUntil` (#2257) via NachoSoto (@NachoSoto) * PurchaseTester: Add Receipt Inspector UI (#2249) via Andy Boedo (@aboedo) * Adds dependabot (#2259) via Cesar de la Vega (@vegaro) * `StoreKit1WrapperTests`: avoid using `Bool.random` to fix flaky code coverage (#2258) via NachoSoto (@NachoSoto) * `IntroEligibilityCalculator`: changed logic to handle products with no subscription group (#2247) via NachoSoto (@NachoSoto)
HTTPClientTest.testRequestIsRetriedIfResponseFromETagManagerIsNil
was actually failing (the request wasn't successful), but because it had no expectations, we didn't notice until we introduced Code Coverage.As you can see in the Codecov diff:
Most of the time that code didn't have coverage (meaning we weren't testing it). The reason for why is uncovered in this PR.
The random execution order meant that sometimes (most of the time) tests like
testHandlesRealErrorConditions
were running first, which did this:That seemingly innocuous code was modifying
HTTPStubsResponse.emptySuccessResponse
, defined in an extension in that file. Being used to value types nobody thought much of that, but unfortunatelyHTTPStubsResponse
is a class, therefore it's a mutable type with reference semantics. Because of that, every test executed after any of these modifying the response would receive a failure, but it was going unnoticed.This PR also introduces a couple improvements to how we wait for several concurrent requests (which I thought was the issue at first).