diff --git a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt index b13b1fa24..9809c0090 100644 --- a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -1,6 +1,7 @@ package dev.gitlive.firebase import kotlin.test.Test +import kotlin.test.assertEquals expect val context: Any expect fun runTest(test: suspend () -> Unit) @@ -21,6 +22,12 @@ class FirebaseAppTest { gcmSenderId = "846484016111" ) ) + + assertEquals(1, Firebase.apps(context).size) + + Firebase.apps(context).forEach { + it.delete() + } } } \ No newline at end of file diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 9dd68b31a..3b6f5df77 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -37,6 +37,13 @@ class FirebaseAuthTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testSignInWithUsernameAndPassword() = runTest { val uid = getTestUid("test@test.com", "test123") diff --git a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 2e54c1d13..9d62b0253 100644 --- a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -50,6 +50,9 @@ class FirebaseRemoteConfigTest { @AfterTest fun tearDown() = runTest { Firebase.remoteConfig.reset() + Firebase.apps(context).forEach { + it.delete() + } } @Test diff --git a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 78188aebd..a50585bd0 100644 --- a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -10,6 +10,7 @@ import dev.gitlive.firebase.apps import dev.gitlive.firebase.initialize import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.test.TestResult +import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertFalse @@ -41,6 +42,13 @@ class FirebaseCrashlyticsTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testRecordException() = runTest { diff --git a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt index 2a339c495..14f921962 100644 --- a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -40,6 +40,13 @@ class FirebaseDatabaseTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testSetValue() = runTest { val testValue = "test" diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 3156416af..e7b0fd106 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -19,6 +19,7 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.Serializable import kotlinx.serialization.builtins.nullable import kotlin.random.Random +import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals @@ -69,6 +70,13 @@ class FirebaseFirestoreTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testStringOrderBy() = runTest { setupFirestoreData() diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 053aefb1d..f2ef6ae2a 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -39,6 +39,13 @@ class FirebasePerformanceTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testNewTrace() = runTest { diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 1712a7beb..8a71f4902 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -16,7 +16,9 @@ actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { + test() +} @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest