Support forcing server errors for tests#1008
Conversation
| requestHeaders: Map<String, String>, | ||
| refreshETag: Boolean = false | ||
| ): HTTPResult { | ||
| if (appConfig.forceServerErrors) { |
There was a problem hiding this comment.
In iOS, we additionally have a compile time flag so this is only available for debug builds. It's possible to split that up in Android by having different versions in debug/release folders but not sure it's worth it...
There was a problem hiding this comment.
Maybe at least make the log in the line below a warning like I did in iOS? It's a pretty important thing if it's happening in a context that we don't expect.
| if (callResult == null) { | ||
| log(LogIntent.WARNING, NetworkStrings.ETAG_RETRYING_CALL) | ||
| return performRequest(baseURL, endpoint, body, requestHeaders, refreshETag = true) | ||
| callResult = performRequest(baseURL, endpoint, body, requestHeaders, refreshETag = true) |
There was a problem hiding this comment.
Changed this to make the linter happy (Too many returns)
| proxyURL: URL?, | ||
| overrideBillingAbstract: BillingAbstract? = null | ||
| overrideBillingAbstract: BillingAbstract? = null, | ||
| forceServerErrors: Boolean = false |
There was a problem hiding this comment.
Note that there are 2 ways of setting the flag, when first initializing the SDK (from tests) or dynamically later by changing the flag in AppConfig. The reason for that is to be able to test situations with a fresh install where all requests fail initially. Otherwise, the initial requests performed during the SDK initialization won't be forced to be errors.
Codecov Report
@@ Coverage Diff @@
## main #1008 +/- ##
==========================================
+ Coverage 85.34% 85.35% +0.01%
==========================================
Files 168 168
Lines 5984 5997 +13
Branches 835 837 +2
==========================================
+ Hits 5107 5119 +12
Misses 546 546
- Partials 331 332 +1
|
| } | ||
|
|
||
| @Test | ||
| fun `can dynamically change between getting server errors and not`() { |
| proxyURL: URL?, | ||
| overrideBillingAbstract: BillingAbstract? = null | ||
| overrideBillingAbstract: BillingAbstract? = null, | ||
| forceServerErrors: Boolean = false |
**This is an automatic release.** ### New Features * Support DEFERRED mode (#985) via swehner (@swehner) * Add completion callback to syncPurchases API (#1002) via Toni Rico (@tonidero) ### Bugfixes * Workaround bug in android 4 for JSON objects with List<String> (#942) via Andy Boedo (@aboedo) ### Dependency Updates * Bump fastlane-plugin-revenuecat_internal from `fe45299` to `13773d2` (#1015) via dependabot[bot] (@dependabot[bot]) ### Other Changes * Bump dokka to 1.8.10 to support Gradle 8 (#1009) via Toni Rico (@tonidero) * Disable offline entitlements temporarily (#1023) via Toni Rico (@tonidero) * Fix integration tests in CI (#1019) via Toni Rico (@tonidero) * Add offline entitlements integration tests (#1006) via Toni Rico (@tonidero) * Disable offline entitlements in observer mode (#1014) via Toni Rico (@tonidero) * Extracts setup and teardown to BasePurchasesTest (#1011) via Cesar de la Vega (@vegaro) * Support forcing server errors for tests (#1008) via Toni Rico (@tonidero) --------- Co-authored-by: revenuecat-ops <ops@revenuecat.com> Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
Description
In iOS, this flag lives within
DangerousSettings. In Android, that's not possible due to our module setup, so I moved this flag toAppConfig, which is internal, so there won't be a public API.