Skip to content
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

Fix integration tests and change to a different project #1123

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ open class BasePurchasesIntegrationTest {
protected val testUserId = "android-integration-test-$currentTimestamp"
protected val proxyUrl = Constants.proxyUrl.takeIf { it != "NO_PROXY_URL" }

protected lateinit var mockBillingAbstract: BillingAbstract
internal lateinit var mockBillingAbstract: BillingAbstract

protected var latestPurchasesUpdatedListener: BillingAbstract.PurchasesUpdatedListener? = null
protected var latestStateListener: BillingAbstract.StateListener? = null
internal var latestPurchasesUpdatedListener: BillingAbstract.PurchasesUpdatedListener? = null
private var latestStateListener: BillingAbstract.StateListener? = null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to change the visibility of these after #1106, otherwise it wouldn't compile


// We shouldn't cache the whole activity, but considering that these are simple integration tests
// and we don't perform any configuration changes, it shouldn't cause any leaks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class PurchasesIntegrationTest : BasePurchasesIntegrationTest() {
onSuccess = { offerings ->
assertThat(offerings.current).isNotNull
assertThat(offerings.current?.availablePackages?.size).isEqualTo(1)
assertThat(offerings.current?.monthly?.product?.sku).isEqualTo(Constants.productIdToPurchase)
assertThat(offerings.current?.annual?.product?.sku).isEqualTo(Constants.productIdToPurchase)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the project to a new one that only has an annual sku. The idea behind that is that we plan to have a real purchase of an annual sku so we can do better integration tests


assertThat(offerings.current?.metadata).isNotNull
assertThat(offerings.current?.metadata?.get("dontdeletethis")).isEqualTo("useforintegrationtesting")
Expand All @@ -114,7 +114,7 @@ class PurchasesIntegrationTest : BasePurchasesIntegrationTest() {
onSuccess = { offerings ->
assertThat(offerings.current).isNotNull
assertThat(offerings.current?.availablePackages?.size).isEqualTo(1)
assertThat(offerings.current?.monthly?.product?.sku).isEqualTo(Constants.productIdToPurchase)
assertThat(offerings.current?.annual?.product?.sku).isEqualTo(Constants.productIdToPurchase)
latch.countDown()
},
)
Expand All @@ -128,7 +128,7 @@ class PurchasesIntegrationTest : BasePurchasesIntegrationTest() {
onSuccess = { newOfferings ->
assertThat(newOfferings.current).isNotNull
assertThat(newOfferings.current?.availablePackages?.size).isEqualTo(1)
assertThat(newOfferings.current?.monthly?.product?.sku).isEqualTo(Constants.productIdToPurchase)
assertThat(newOfferings.current?.annual?.product?.sku).isEqualTo(Constants.productIdToPurchase)

latch.countDown()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.revenuecat.purchases.models.StoreProduct
import io.mockk.every
import io.mockk.slot

fun BillingAbstract.mockQueryProductDetails(
internal fun BillingAbstract.mockQueryProductDetails(
queryProductDetailsSubsReturn: List<StoreProduct> = listOf(StoreProductFactory.createGoogleStoreProduct()),
queryProductDetailsInAppReturn: List<StoreProduct> = emptyList(),
): BillingAbstract {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class BaseOfflineEntitlementsIntegrationTest : BasePurchasesIntegration
)

// Hack until we get a running token for production API tests. After that, we can just use "entitlementsToVerify"
private val expectedEntitlements = entitlementsToVerify.ifEmpty { listOf("pro_cat", "another_pro_4") }
private val expectedEntitlements = entitlementsToVerify.ifEmpty { listOf("pro_cat") }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed as part of the changes to the new project.


// region helpers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.revenuecat.purchases
import android.annotation.SuppressLint
import com.revenuecat.purchases.common.BillingAbstract

fun Purchases.Companion.configure(
internal fun Purchases.Companion.configure(
configuration: PurchasesConfiguration,
overrideBillingAbstract: BillingAbstract,
forceServerErrors: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ internal class ProductionBackendIntegrationTest: BaseBackendIntegrationTest() {
ensureBlockFinishes { latch ->
backend.getProductEntitlementMapping(
onSuccessHandler = { productEntitlementMapping ->
assertThat(productEntitlementMapping.mappings.size).isEqualTo(36)
assertThat(productEntitlementMapping.mappings["annual_freetrial"]).isEqualTo(
assertThat(productEntitlementMapping.mappings.size).isEqualTo(2)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also needed as part of the changes to the new project.

assertThat(productEntitlementMapping.mappings["cheapest_subs"]).isEqualTo(
ProductEntitlementMapping.Mapping(
productIdentifier = "annual_freetrial",
basePlanId = "p1y",
productIdentifier = "cheapest_subs",
basePlanId = "annual",
entitlements = listOf("pro_cat")
)
)
Expand Down