-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some tests still failing. To discuss in ticket
- Loading branch information
Showing
10 changed files
with
91 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dev.gitlive.firebase.firestore | ||
|
||
import dev.gitlive.firebase.testContext | ||
|
||
actual val emulatorHost: String = "localhost" | ||
|
||
actual val context: Any = testContext | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
actual fun encodedAsMap(encoded: Any?): Map<String, Any?> = encoded as Map<String, Any?> | ||
actual fun Map<String, Any?>.asEncoded(): Any = this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test-utils/src/jvmMain/kotlin/dev/gitlive/firebase/TestUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@file:JvmName("TestUtilsJvm") | ||
/* | ||
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.gitlive.firebase | ||
|
||
import android.app.Application | ||
import com.google.firebase.FirebasePlatform | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.runBlocking | ||
import kotlin.time.Duration.Companion.minutes | ||
|
||
val testContext = Application().apply { | ||
FirebasePlatform.initializeFirebasePlatform(object : FirebasePlatform() { | ||
val storage = mutableMapOf<String, String>() | ||
override fun store(key: String, value: String) = storage.set(key, value) | ||
override fun retrieve(key: String) = storage[key] | ||
override fun clear(key: String) { storage.remove(key) } | ||
override fun log(msg: String) = println(msg) | ||
}) | ||
} | ||
|
||
actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } | ||
actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) = runBlocking(block = action) | ||
|
||
actual fun nativeMapOf(vararg pairs: Pair<Any, Any?>): Any = mapOf(*pairs) | ||
actual fun nativeListOf(vararg elements: Any?): Any = listOf(*elements) | ||
actual fun nativeAssertEquals(expected: Any?, actual: Any?) { | ||
kotlin.test.assertEquals(expected, actual) | ||
} |