Skip to content

Commit 83f0192

Browse files
committed
Make raw internal/Disable Android DB test
1 parent 6ba3fa0 commit 83f0192

File tree

11 files changed

+23
-10
lines changed

11 files changed

+23
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@file:JvmName("AndroidEncodedObject")
22
package dev.gitlive.firebase.internal
33

4-
val EncodedObject.android: Map<String, Any?> get() = raw
4+
val EncodedObject.android: Map<String, Any?> get() = getRaw()
55

66
@PublishedApi
77
internal actual fun Any.asNativeMap(): Map<*, *>? = this as? Map<*, *>

firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import kotlin.jvm.JvmInline
66
* Platform specific object for storing encoded data that can be used for methods that explicitly require an object.
77
* This is essentially a [Map] of [String] and [Any]? (as represented by [raw]) but since [encode] gives a platform specific value, this method wraps that.
88
*/
9-
sealed interface EncodedObject {
10-
val raw: Map<String, Any?>
9+
sealed interface EncodedObject
10+
11+
internal fun EncodedObject.getRaw(): Map<String, Any?> = when (this) {
12+
is EncodedObjectImpl -> raw
1113
}
1214

1315
@JvmInline
1416
@PublishedApi
15-
internal value class EncodedObjectImpl(override val raw: Map<String, Any?>) : EncodedObject
17+
internal value class EncodedObjectImpl(val raw: Map<String, Any?>) : EncodedObject
1618

1719
@PublishedApi
1820
internal expect fun Any.asNativeMap(): Map<*, *>?

firebase-common-internal/src/commonTest/kotlin/dev/gitlive/firebase/internal/EncodersTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,12 @@ class EncodersTest {
428428
testDataClass
429429
) { encodeDefaults = false }
430430

431-
nativeAssertEquals(mapOf("map" to nativeMapOf("key" to "value"), "otherMap" to nativeMapOf(1 to 1), "bool" to true, "valueClass" to 42), encodedObject.raw)
431+
nativeAssertEquals(mapOf("map" to nativeMapOf("key" to "value"), "otherMap" to nativeMapOf(1 to 1), "bool" to true, "valueClass" to 42), encodedObject.getRaw())
432432

433433
val testMap = mapOf("one" to 1, "two" to null, "three" to false)
434-
assertEquals(testMap, encodeAsObject(testMap).raw)
434+
assertEquals(testMap, encodeAsObject(testMap).getRaw())
435435

436-
assertEquals(emptyMap(), encodeAsObject(TestObject).raw)
436+
assertEquals(emptyMap(), encodeAsObject(TestObject).getRaw())
437437

438438
assertFailsWith<IllegalArgumentException> {
439439
encodeAsObject(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dev.gitlive.firebase.internal
22

3-
val EncodedObject.ios: Map<Any?, *> get() = raw.mapKeys { (key, _) -> key }
3+
val EncodedObject.ios: Map<Any?, *> get() = getRaw().mapKeys { (key, _) -> key }
44

55
@PublishedApi
66
internal actual fun Any.asNativeMap(): Map<*, *>? = this as? Map<*, *>

firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dev.gitlive.firebase.internal
33
import kotlin.js.Json
44
import kotlin.js.json
55

6-
val EncodedObject.js: Json get() = json(*raw.entries.map { (key, value) -> key to value }.toTypedArray())
6+
val EncodedObject.js: Json get() = json(*getRaw().entries.map { (key, value) -> key to value }.toTypedArray())
77

88
@PublishedApi
99
internal actual fun Any.asNativeMap(): Map<*, *>? {

firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
package dev.gitlive.firebase.database
77

88
import androidx.test.platform.app.InstrumentationRegistry
9+
import org.junit.Ignore
910

1011
actual val emulatorHost: String = "10.0.2.2"
1112

1213
actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext
1314
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
1415
actual annotation class IgnoreForAndroidUnitTest
16+
17+
actual typealias IgnoreForAndroidTest = Ignore

firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ actual val emulatorHost: String = "10.0.2.2"
1111

1212
actual val context: Any = ""
1313
actual typealias IgnoreForAndroidUnitTest = Ignore
14+
actual typealias IgnoreForAndroidTest = Ignore

firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import kotlin.time.Duration.Companion.minutes
2525
expect val emulatorHost: String
2626
expect val context: Any
2727
expect annotation class IgnoreForAndroidUnitTest()
28+
expect annotation class IgnoreForAndroidTest()
2829

2930
@IgnoreForAndroidUnitTest
3031
class FirebaseDatabaseTest {
@@ -197,6 +198,8 @@ class FirebaseDatabaseTest {
197198
assertFalse(valueEvents.first().exists)
198199
}
199200

201+
// Ignoring on Android Instrumented Tests due to bug in Firebase: https://github.com/firebase/firebase-android-sdk/issues/5870
202+
@IgnoreForAndroidTest
200203
@Test
201204
fun testUpdateChildrenOnDisconnect() = runTest {
202205
setupRealtimeData()

firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ actual val context: Any = Unit
1010

1111
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
1212
actual annotation class IgnoreForAndroidUnitTest
13+
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
14+
actual annotation class IgnoreForAndroidTest

firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ actual val context: Any = Unit
66

77
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
88
actual annotation class IgnoreForAndroidUnitTest
9+
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
10+
actual annotation class IgnoreForAndroidTest

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ gradlePluginVersion=8.1.3
6767
kotlinVersion=1.9.21
6868
coroutinesVersion=1.7.3
6969
serializationVersion=1.6.0
70-
firebaseBoMVersion=32.7.0
70+
firebaseBoMVersion=32.8.1
7171
apiVersion=1.8
7272
languageVersion=1.9

0 commit comments

Comments
 (0)