-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose runInScreenScope job. fix/cleanup tests
- Loading branch information
Showing
8 changed files
with
54 additions
and
66 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
14 changes: 2 additions & 12 deletions
14
shared/src/androidUnitTest/kotlin/eu/baroncelli/dkmpsample/shared/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
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
50 changes: 34 additions & 16 deletions
50
shared/src/commonTest/kotlin/eu/baroncelli/dkmpsample/shared/viewmodel/Tests.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
16 changes: 3 additions & 13 deletions
16
shared/src/desktopTest/kotlin/eu/baroncelli/dkmpsample/shared/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 |
---|---|---|
@@ -1,22 +1,12 @@ | ||
package eu.baroncelli.dkmpsample.shared | ||
|
||
import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver | ||
import com.russhwolf.settings.MapSettings | ||
import eu.baroncelli.dkmpsample.shared.datalayer.Repository | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.newSingleThreadContext | ||
import kotlinx.coroutines.runBlocking | ||
import kotlin.coroutines.CoroutineContext | ||
import app.cash.sqldelight.sqlite.driver.JdbcSqliteDriver | ||
import mylocal.db.LocalDb | ||
|
||
actual val testCoroutineContext: CoroutineContext = | ||
newSingleThreadContext("testRunner") | ||
|
||
actual fun runBlockingTest(block: suspend CoroutineScope.() -> Unit) = | ||
runBlocking(testCoroutineContext) { this.block() } | ||
|
||
actual fun getTestRepository() : Repository { | ||
actual suspend fun getTestRepository(): Repository { | ||
val sqlDriver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY) | ||
LocalDb.Schema.create(sqlDriver) | ||
LocalDb.Schema.create(sqlDriver).await() | ||
return Repository(sqlDriver, MapSettings(), false) | ||
} |
14 changes: 2 additions & 12 deletions
14
shared/src/iosTest/kotlin/eu/baroncelli/dkmpsample/shared/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 |
---|---|---|
@@ -1,21 +1,11 @@ | ||
package eu.baroncelli.dkmpsample.shared | ||
|
||
import app.cash.sqldelight.driver.native.NativeSqliteDriver | ||
import com.russhwolf.settings.MapSettings | ||
import eu.baroncelli.dkmpsample.shared.datalayer.Repository | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.newSingleThreadContext | ||
import kotlinx.coroutines.runBlocking | ||
import kotlin.coroutines.CoroutineContext | ||
import app.cash.sqldelight.drivers.native.NativeSqliteDriver | ||
import mylocal.db.LocalDb | ||
|
||
actual val testCoroutineContext: CoroutineContext = | ||
newSingleThreadContext("testRunner") | ||
|
||
actual fun runBlockingTest(block: suspend CoroutineScope.() -> Unit) = | ||
runBlocking(testCoroutineContext) { this.block() } | ||
|
||
actual fun getTestRepository() : Repository { | ||
actual suspend fun getTestRepository(): Repository { | ||
val sqlDriver = NativeSqliteDriver(LocalDb.Schema, "test.db") | ||
return Repository(sqlDriver, MapSettings(), false) | ||
} |