From 1c37b33a6929fd08fb1bb80cd3ca400092b3e2ae Mon Sep 17 00:00:00 2001 From: toluo-stripe Date: Thu, 30 Jan 2025 00:13:53 -0500 Subject: [PATCH] clear linkAccountManager for each LinkTest --- .../java/com/stripe/android/paymentsheet/LinkTest.kt | 7 +++++++ .../android/link/injection/LinkAccountManagerModule.kt | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/LinkTest.kt b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/LinkTest.kt index e1bd5fd1559..910b7bffe24 100644 --- a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/LinkTest.kt +++ b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/LinkTest.kt @@ -6,6 +6,7 @@ import com.google.testing.junit.testparameterinjector.TestParameter import com.google.testing.junit.testparameterinjector.TestParameterInjector import com.stripe.android.core.utils.urlEncode import com.stripe.android.link.account.LinkStore +import com.stripe.android.link.injection.LinkAccountManagerModule import com.stripe.android.networktesting.NetworkRule import com.stripe.android.networktesting.RequestMatcher import com.stripe.android.networktesting.RequestMatchers.bodyPart @@ -21,6 +22,7 @@ import com.stripe.android.paymentsheet.utils.ProductIntegrationTypeProvider import com.stripe.android.paymentsheet.utils.TestRules import com.stripe.android.paymentsheet.utils.assertCompleted import com.stripe.android.paymentsheet.utils.runProductIntegrationTest +import org.junit.After import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -43,6 +45,11 @@ internal class LinkTest { @TestParameter(valuesProvider = ProductIntegrationTypeProvider::class) lateinit var integrationType: ProductIntegrationType + @After + fun clearLinkAccountManagerModule() { + LinkAccountManagerModule.clear() + } + @Test fun testSuccessfulCardPaymentWithLinkSignUp() = runProductIntegrationTest( networkRule = networkRule, diff --git a/paymentsheet/src/main/java/com/stripe/android/link/injection/LinkAccountManagerModule.kt b/paymentsheet/src/main/java/com/stripe/android/link/injection/LinkAccountManagerModule.kt index 36131e1321c..111b53fabab 100644 --- a/paymentsheet/src/main/java/com/stripe/android/link/injection/LinkAccountManagerModule.kt +++ b/paymentsheet/src/main/java/com/stripe/android/link/injection/LinkAccountManagerModule.kt @@ -1,5 +1,6 @@ package com.stripe.android.link.injection +import androidx.annotation.VisibleForTesting import com.stripe.android.link.LinkConfiguration import com.stripe.android.link.account.DefaultLinkAccountManager import com.stripe.android.link.account.LinkAccountManager @@ -33,4 +34,9 @@ internal object LinkAccountManagerModule { } } } + + @VisibleForTesting + fun clear() { + linkAccountManager = null + } }