Extracts setup and teardown to BasePurchasesTest#1011
Conversation
| protected val randomAppUserId = "\$RCAnonymousID:ff68f26e432648369a713849a9f93b58" | ||
| protected val appUserId = "fakeUserID" | ||
| protected lateinit var purchases: Purchases | ||
| protected val mockInfo = mockk<CustomerInfo>() |
There was a problem hiding this comment.
I kept here properties that are used in BasePurchasesTest, whatever is only used in PurchasesTest, meaning it's not needed for setup and teardown is kept in Purchases.kt
Whatever is in this new class has been directly copied from Purchases.kt
| @@ -143,43 +116,7 @@ class PurchasesTest { | |||
|
|
|||
| private val mockLifecycle = mockk<Lifecycle>() | |||
| private val mockLifecycleOwner = mockk<LifecycleOwner>() | |||
There was a problem hiding this comment.
There might be some properties that will probably be needed by different test classes and could be moved to BasePurchasesTest, but we can extract them whenever we need to.
| queriedINAPP = emptyMap(), | ||
| notInCache = listOf(activePurchasedPurchase, activePendingPurchase, activeUnspecifiedPurchase) | ||
| ) | ||
| val productInfo = mockQueryingProductDetails("product", ProductType.SUBS, null) |
There was a problem hiding this comment.
lol I broke this test for not thinking haha
tonidero
left a comment
There was a problem hiding this comment.
Nice!! We are chipping away that PurchasesTest class 💪
| protected lateinit var purchases: Purchases | ||
| protected val mockInfo = mockk<CustomerInfo>() | ||
|
|
||
| @After |
There was a problem hiding this comment.
Total nitpick but I kinda prefer to have the @After after the @Before 😅
| } | ||
|
|
||
| protected fun buildPurchases(anonymous: Boolean, autoSync: Boolean = true) { | ||
| purchases = Purchases( |
There was a problem hiding this comment.
I think the only other place we build this in tests currently is in SubscriberAttributesPurchasesTests. Might be good trying to have that use this BasePurchasesTest. But we can do that as a followup.
There was a problem hiding this comment.
let's do it as a followup, otherwise the pr gets harder to review
|
oh weird one test is failing 🤔 |
Codecov Report
@@ Coverage Diff @@
## main #1011 +/- ##
=======================================
Coverage 85.35% 85.35%
=======================================
Files 168 168
Lines 5997 5997
Branches 837 837
=======================================
Hits 5119 5119
Misses 546 546
Partials 332 332 |
**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>
Extracted
setupandtearDownfromPurchasesTest.ktso it's easier not only to splitPurchases.ktinto different test files, but also it's easier to create new tests that depend on creation of aPurchasesobject.