From d463bb55d75b91608ddb46584fae45b20a7feeb6 Mon Sep 17 00:00:00 2001 From: Alinson Xavier Date: Sat, 13 Apr 2019 19:27:51 -0500 Subject: [PATCH] Unify async tests --- .../kotlin/org/isoron/platform/gui/Canvas.kt | 1 - .../kotlin/org/isoron/platform/io/Database.kt | 2 - .../kotlin/org/isoron/platform/io/Log.kt | 1 - .../org/isoron/uhabits/backend/Backend.kt | 4 +- .../kotlin/org/isoron/AsyncTests.kt | 26 +++++++ .../kotlin/org/isoron/DependencyResolver.kt | 34 +++++++++ .../org/isoron/platform/gui/CanvasTest.kt | 16 ++--- .../org/isoron/platform/io/DatabaseTest.kt | 9 ++- .../org/isoron/platform/io/FilesTest.kt | 7 +- .../uhabits/models/CheckmarkRepositoryTest.kt | 7 +- .../uhabits/models/HabitRepositoryTest.kt | 7 +- .../models/PreferencesRepositoryTest.kt | 7 +- .../kotlin/org/isoron/DependencyResolver.kt | 31 ++++++++ .../kotlin/org/isoron/IosAsyncTests.kt | 13 ++-- .../JsCanvasTest.kt => DependencyResolver.kt} | 35 ++++++++-- .../jsTest/kotlin/org/isoron/JsAsyncTests.kt | 28 ++++++++ .../org/isoron/platform/JsAsyncTests.kt | 70 ------------------- ...avaCanvasTest.kt => DependencyResolver.kt} | 28 ++++++-- .../kotlin/org/isoron/JavaAsyncTests.kt | 48 ++----------- ios/Application/AppDelegate.swift | 2 +- 20 files changed, 217 insertions(+), 159 deletions(-) create mode 100644 core/src/commonTest/kotlin/org/isoron/AsyncTests.kt create mode 100644 core/src/commonTest/kotlin/org/isoron/DependencyResolver.kt create mode 100644 core/src/iosTest/kotlin/org/isoron/DependencyResolver.kt rename core/src/jsTest/kotlin/org/isoron/{platform/JsCanvasTest.kt => DependencyResolver.kt} (62%) create mode 100644 core/src/jsTest/kotlin/org/isoron/JsAsyncTests.kt delete mode 100644 core/src/jsTest/kotlin/org/isoron/platform/JsAsyncTests.kt rename core/src/jvmTest/kotlin/org/isoron/{platform/JavaCanvasTest.kt => DependencyResolver.kt} (64%) diff --git a/core/src/commonMain/kotlin/org/isoron/platform/gui/Canvas.kt b/core/src/commonMain/kotlin/org/isoron/platform/gui/Canvas.kt index 77ecaba7a..b3e1264f9 100644 --- a/core/src/commonMain/kotlin/org/isoron/platform/gui/Canvas.kt +++ b/core/src/commonMain/kotlin/org/isoron/platform/gui/Canvas.kt @@ -23,7 +23,6 @@ enum class TextAlign { LEFT, CENTER, RIGHT } - enum class Font { REGULAR, BOLD, diff --git a/core/src/commonMain/kotlin/org/isoron/platform/io/Database.kt b/core/src/commonMain/kotlin/org/isoron/platform/io/Database.kt index d48b51ebd..ab0409214 100644 --- a/core/src/commonMain/kotlin/org/isoron/platform/io/Database.kt +++ b/core/src/commonMain/kotlin/org/isoron/platform/io/Database.kt @@ -19,8 +19,6 @@ package org.isoron.platform.io -import org.isoron.uhabits.* - interface PreparedStatement { fun step(): StepResult fun finalize() diff --git a/core/src/commonMain/kotlin/org/isoron/platform/io/Log.kt b/core/src/commonMain/kotlin/org/isoron/platform/io/Log.kt index e8c0a10d3..6ea8309f5 100644 --- a/core/src/commonMain/kotlin/org/isoron/platform/io/Log.kt +++ b/core/src/commonMain/kotlin/org/isoron/platform/io/Log.kt @@ -35,5 +35,4 @@ class StandardLog : Log { override fun debug(tag: String, msg: String) { println("D/$tag $msg") } - } \ No newline at end of file diff --git a/core/src/commonMain/kotlin/org/isoron/uhabits/backend/Backend.kt b/core/src/commonMain/kotlin/org/isoron/uhabits/backend/Backend.kt index 029cac4a2..0137d3463 100644 --- a/core/src/commonMain/kotlin/org/isoron/uhabits/backend/Backend.kt +++ b/core/src/commonMain/kotlin/org/isoron/uhabits/backend/Backend.kt @@ -47,8 +47,8 @@ class Backend(private val databaseName: String, private val fileOpener: FileOpener, private val localeHelper: LocaleHelper, private val log: Log, - private val crCtx: CoroutineContext - ) : CoroutineScope by BackendScope(crCtx, log) { + private val scope: CoroutineContext + ) : CoroutineScope by BackendScope(scope, log) { private lateinit var database: Database diff --git a/core/src/commonTest/kotlin/org/isoron/AsyncTests.kt b/core/src/commonTest/kotlin/org/isoron/AsyncTests.kt new file mode 100644 index 000000000..323e2c234 --- /dev/null +++ b/core/src/commonTest/kotlin/org/isoron/AsyncTests.kt @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2016-2019 Álinson Santos Xavier + * + * This file is part of Loop Habit Tracker. + * + * Loop Habit Tracker is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Loop Habit Tracker is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +package org.isoron + +/** + * Workaround until Kotlin adds support for testing suspend functions + * https://youtrack.jetbrains.com/issue/KT-22228 + */ +expect fun asyncTest(block: suspend () -> Unit) \ No newline at end of file diff --git a/core/src/commonTest/kotlin/org/isoron/DependencyResolver.kt b/core/src/commonTest/kotlin/org/isoron/DependencyResolver.kt new file mode 100644 index 000000000..6fe0e97b9 --- /dev/null +++ b/core/src/commonTest/kotlin/org/isoron/DependencyResolver.kt @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2016-2019 Álinson Santos Xavier + * + * This file is part of Loop Habit Tracker. + * + * Loop Habit Tracker is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Loop Habit Tracker is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +package org.isoron + +import org.isoron.platform.gui.* +import org.isoron.platform.io.* + +interface CanvasHelper { + fun createCanvas(width: Int, height: Int): Canvas + fun exportCanvas(canvas: Canvas, filename: String) +} + +expect object DependencyResolver { + suspend fun getFileOpener(): FileOpener + suspend fun getDatabase(): Database + fun getCanvasHelper(): CanvasHelper +} \ No newline at end of file diff --git a/core/src/commonTest/kotlin/org/isoron/platform/gui/CanvasTest.kt b/core/src/commonTest/kotlin/org/isoron/platform/gui/CanvasTest.kt index 8c00765e5..0a54babe7 100644 --- a/core/src/commonTest/kotlin/org/isoron/platform/gui/CanvasTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/platform/gui/CanvasTest.kt @@ -19,9 +19,14 @@ package org.isoron.platform.gui -class CanvasTest(val platform: Platform) { +import org.isoron.* +import kotlin.test.* + +class CanvasTest { + @Test fun run() { - val canvas = platform.createCanvas(500, 400) + val helper = DependencyResolver.getCanvasHelper() + val canvas = helper.createCanvas(500, 400) canvas.setColor(Color(0x303030)) canvas.fillRect(0.0, 0.0, 500.0, 400.0) @@ -61,11 +66,6 @@ class CanvasTest(val platform: Platform) { canvas.setFont(Font.FONT_AWESOME) canvas.drawText(FontAwesome.CHECK, 250.0, 300.0) - platform.exportCanvas(canvas, "CanvasTest.png") - } - - interface Platform { - fun createCanvas(width: Int, height: Int): Canvas - fun exportCanvas(canvas: Canvas, filename: String) + helper.exportCanvas(canvas, "CanvasTest.png") } } \ No newline at end of file diff --git a/core/src/commonTest/kotlin/org/isoron/platform/io/DatabaseTest.kt b/core/src/commonTest/kotlin/org/isoron/platform/io/DatabaseTest.kt index dedb078e9..533ab2489 100644 --- a/core/src/commonTest/kotlin/org/isoron/platform/io/DatabaseTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/platform/io/DatabaseTest.kt @@ -19,10 +19,15 @@ package org.isoron.platform.io +import org.isoron.* import kotlin.test.* -class DatabaseTest(val db: Database) { - fun testUsage() { +class DatabaseTest { + + @Test + fun testUsage() = asyncTest{ + val db = DependencyResolver.getDatabase() + db.setVersion(0) assertEquals(0, db.getVersion()) diff --git a/core/src/commonTest/kotlin/org/isoron/platform/io/FilesTest.kt b/core/src/commonTest/kotlin/org/isoron/platform/io/FilesTest.kt index 38bde3408..36cedaae5 100644 --- a/core/src/commonTest/kotlin/org/isoron/platform/io/FilesTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/platform/io/FilesTest.kt @@ -22,8 +22,11 @@ package org.isoron.platform.io import org.isoron.* import kotlin.test.* -class FilesTest(val fileOpener: FileOpener) { - suspend fun testLines() { +class FilesTest() { + @Test + fun testLines() = asyncTest { + val fileOpener = DependencyResolver.getFileOpener() + assertFalse(fileOpener.openUserFile("non-existing-usr.txt").exists(), "non-existing-usr.txt shouldn't exist") diff --git a/core/src/commonTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt b/core/src/commonTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt index 90c929078..cdc97b17e 100644 --- a/core/src/commonTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt @@ -25,8 +25,11 @@ import org.isoron.platform.time.* import kotlin.test.* -class CheckmarkRepositoryTest(val db: Database) { - fun testCRUD() { +class CheckmarkRepositoryTest() { + @Test + fun testCRUD() = asyncTest { + val db = DependencyResolver.getDatabase() + val habitA = 10 var checkmarksA = listOf(Checkmark(LocalDate(2019, 1, 15), 100), Checkmark(LocalDate(2019, 1, 7), 500), diff --git a/core/src/commonTest/kotlin/org/isoron/uhabits/models/HabitRepositoryTest.kt b/core/src/commonTest/kotlin/org/isoron/uhabits/models/HabitRepositoryTest.kt index d7b72a316..faa234d78 100644 --- a/core/src/commonTest/kotlin/org/isoron/uhabits/models/HabitRepositoryTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/uhabits/models/HabitRepositoryTest.kt @@ -21,11 +21,12 @@ package org.isoron.uhabits.models import org.isoron.* import org.isoron.platform.gui.* -import org.isoron.platform.io.* import kotlin.test.* -class HabitRepositoryTest(val db: Database) { - fun testCRUD() { +class HabitRepositoryTest() { + @Test + fun testCRUD() = asyncTest{ + val db = DependencyResolver.getDatabase() val original0 = Habit(id = 0, name = "Wake up early", description = "Did you wake up before 6am?", diff --git a/core/src/commonTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt b/core/src/commonTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt index 4f1849730..b24b65ecb 100644 --- a/core/src/commonTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt @@ -19,11 +19,14 @@ package org.isoron.uhabits.models +import org.isoron.* import org.isoron.platform.io.* import kotlin.test.* -class PreferencesRepositoryTest(val db: Database) { - fun testUsage() { +class PreferencesRepositoryTest() { + @Test + fun testUsage() = asyncTest{ + val db = DependencyResolver.getDatabase() val prefs = PreferencesRepository(db) assertEquals("default", prefs.getString("non_existing_key", "default")) prefs.putString("ringtone_path", "/tmp") diff --git a/core/src/iosTest/kotlin/org/isoron/DependencyResolver.kt b/core/src/iosTest/kotlin/org/isoron/DependencyResolver.kt new file mode 100644 index 000000000..36bedb4c7 --- /dev/null +++ b/core/src/iosTest/kotlin/org/isoron/DependencyResolver.kt @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2016-2019 Álinson Santos Xavier + * + * This file is part of Loop Habit Tracker. + * + * Loop Habit Tracker is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Loop Habit Tracker is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +package org.isoron + +import org.isoron.platform.io.* + +actual object DependencyResolver { + actual suspend fun getFileOpener(): FileOpener = IosFileOpener() + + // IosDatabase and IosCanvas are currently implemented in Swift, so we + // cannot test these classes here. + actual suspend fun getDatabase(): Database = TODO() + actual fun getCanvasHelper(): CanvasHelper = TODO() +} \ No newline at end of file diff --git a/core/src/iosTest/kotlin/org/isoron/IosAsyncTests.kt b/core/src/iosTest/kotlin/org/isoron/IosAsyncTests.kt index 12b02f9a8..711209fc3 100644 --- a/core/src/iosTest/kotlin/org/isoron/IosAsyncTests.kt +++ b/core/src/iosTest/kotlin/org/isoron/IosAsyncTests.kt @@ -20,12 +20,9 @@ package org.isoron import kotlinx.coroutines.* -import org.isoron.platform.io.* -import kotlin.test.* -class IosAsyncTests { - @Test - fun testFiles() = runBlocking { - FilesTest(IosFileOpener()).testLines() - } -} \ No newline at end of file +/** + * Workaround until Kotlin adds support for testing suspend functions + * https://youtrack.jetbrains.com/issue/KT-22228 + */ +actual fun asyncTest(block: suspend () -> Unit) = runBlocking { block() } diff --git a/core/src/jsTest/kotlin/org/isoron/platform/JsCanvasTest.kt b/core/src/jsTest/kotlin/org/isoron/DependencyResolver.kt similarity index 62% rename from core/src/jsTest/kotlin/org/isoron/platform/JsCanvasTest.kt rename to core/src/jsTest/kotlin/org/isoron/DependencyResolver.kt index 8f003324d..4611a2e5f 100644 --- a/core/src/jsTest/kotlin/org/isoron/platform/JsCanvasTest.kt +++ b/core/src/jsTest/kotlin/org/isoron/DependencyResolver.kt @@ -17,14 +17,40 @@ * with this program. If not, see . */ -package org.isoron.platform +package org.isoron import org.isoron.platform.gui.* +import org.isoron.platform.io.* +import org.isoron.uhabits.* import org.w3c.dom.* import kotlin.browser.* -import kotlin.test.* -class JsCanvasTest : CanvasTest.Platform { +actual object DependencyResolver { + + var fileOpener: JsFileOpener? = null + + actual suspend fun getFileOpener(): FileOpener { + if (fileOpener == null) { + val fs = JsFileStorage() + fs.init() + fileOpener = JsFileOpener(fs) + } + return fileOpener!! + } + + actual suspend fun getDatabase(): Database { + val nativeDB = eval("new SQL.Database()") + val db = JsDatabase(nativeDB) + db.migrateTo(LOOP_DATABASE_VERSION, getFileOpener(), StandardLog()) + return db + } + + actual fun getCanvasHelper(): CanvasHelper { + return JsCanvasHelper() + } +} + +class JsCanvasHelper : CanvasHelper { override fun createCanvas(width: Int, height: Int): Canvas { val canvasElement = document.getElementById("canvas") as HTMLCanvasElement canvasElement.style.width = "${width}px" @@ -35,7 +61,4 @@ class JsCanvasTest : CanvasTest.Platform { override fun exportCanvas(canvas: Canvas, filename: String) { // do nothing } - - @Test - fun testDrawing() = CanvasTest(this).run() } \ No newline at end of file diff --git a/core/src/jsTest/kotlin/org/isoron/JsAsyncTests.kt b/core/src/jsTest/kotlin/org/isoron/JsAsyncTests.kt new file mode 100644 index 000000000..6281be452 --- /dev/null +++ b/core/src/jsTest/kotlin/org/isoron/JsAsyncTests.kt @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2016-2019 Álinson Santos Xavier + * + * This file is part of Loop Habit Tracker. + * + * Loop Habit Tracker is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Loop Habit Tracker is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +package org.isoron + +import kotlinx.coroutines.* + +/** + * Workaround until Kotlin adds support for testing suspend functions + * https://youtrack.jetbrains.com/issue/KT-22228 + */ +actual fun asyncTest(block: suspend () -> Unit): dynamic = GlobalScope.promise { block() } diff --git a/core/src/jsTest/kotlin/org/isoron/platform/JsAsyncTests.kt b/core/src/jsTest/kotlin/org/isoron/platform/JsAsyncTests.kt deleted file mode 100644 index 9925da221..000000000 --- a/core/src/jsTest/kotlin/org/isoron/platform/JsAsyncTests.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron - -import kotlinx.coroutines.* -import org.isoron.platform.io.* -import org.isoron.uhabits.* -import org.isoron.uhabits.models.* -import kotlin.test.* - -class JsAsyncTests { - var fs: JsFileStorage? = null - - suspend fun getFileOpener(): FileOpener { - if (fs == null) { - fs = JsFileStorage() - fs?.init() - } - return JsFileOpener(fs!!) - } - - suspend fun getDatabase(): Database { - val nativeDB = eval("new SQL.Database()") - val db = JsDatabase(nativeDB) - db.migrateTo(LOOP_DATABASE_VERSION, getFileOpener(), StandardLog()) - return db - } - - @Test - fun testFiles() = GlobalScope.promise { - FilesTest(getFileOpener()).testLines() - } - - @Test - fun testDatabase() = GlobalScope.promise { - DatabaseTest(getDatabase()).testUsage() - } - - @Test - fun testCheckmarkRepository() = GlobalScope.promise { - CheckmarkRepositoryTest(getDatabase()).testCRUD() - } - - @Test - fun testHabitRepository() = GlobalScope.promise { - HabitRepositoryTest(getDatabase()).testCRUD() - } - - @Test - fun testPreferencesRepository() = GlobalScope.promise { - PreferencesRepositoryTest(getDatabase()).testUsage() - } -} \ No newline at end of file diff --git a/core/src/jvmTest/kotlin/org/isoron/platform/JavaCanvasTest.kt b/core/src/jvmTest/kotlin/org/isoron/DependencyResolver.kt similarity index 64% rename from core/src/jvmTest/kotlin/org/isoron/platform/JavaCanvasTest.kt rename to core/src/jvmTest/kotlin/org/isoron/DependencyResolver.kt index 334500c9e..22a393c18 100644 --- a/core/src/jvmTest/kotlin/org/isoron/platform/JavaCanvasTest.kt +++ b/core/src/jvmTest/kotlin/org/isoron/DependencyResolver.kt @@ -17,15 +17,34 @@ * with this program. If not, see . */ -package org.isoron.platform +package org.isoron import org.isoron.platform.gui.* -import org.junit.* +import org.isoron.platform.io.* +import org.isoron.uhabits.* import java.awt.image.* import java.io.* import javax.imageio.* -class JavaCanvasTest : CanvasTest.Platform { +actual object DependencyResolver { + actual suspend fun getFileOpener(): FileOpener = JavaFileOpener() + actual fun getCanvasHelper(): CanvasHelper = JavaCanvasHelper() + + actual suspend fun getDatabase(): Database { + val log = StandardLog() + val fileOpener = JavaFileOpener() + val databaseOpener = JavaDatabaseOpener(log) + + val dbFile = fileOpener.openUserFile("test.sqlite3") + if (dbFile.exists()) dbFile.delete() + val db = databaseOpener.open(dbFile) + db.migrateTo(LOOP_DATABASE_VERSION, fileOpener, log) + return db + } + +} + +class JavaCanvasHelper : CanvasHelper { override fun createCanvas(width: Int, height: Int): Canvas { val image = BufferedImage(width, height, BufferedImage.TYPE_INT_RGB) return JavaCanvas(image, pixelScale = 1.0) @@ -35,7 +54,4 @@ class JavaCanvasTest : CanvasTest.Platform { val javaCanvas = canvas as JavaCanvas ImageIO.write(javaCanvas.image, "png", File("/tmp/$filename")) } - - @Test - fun testDrawing() = CanvasTest(this).run() } \ No newline at end of file diff --git a/core/src/jvmTest/kotlin/org/isoron/JavaAsyncTests.kt b/core/src/jvmTest/kotlin/org/isoron/JavaAsyncTests.kt index 32ad8b063..711209fc3 100644 --- a/core/src/jvmTest/kotlin/org/isoron/JavaAsyncTests.kt +++ b/core/src/jvmTest/kotlin/org/isoron/JavaAsyncTests.kt @@ -20,47 +20,9 @@ package org.isoron import kotlinx.coroutines.* -import org.isoron.platform.io.* -import org.isoron.uhabits.* -import org.isoron.uhabits.models.* -import org.junit.* -class JavaAsyncTests { - - val log = StandardLog() - val fileOpener = JavaFileOpener() - val databaseOpener = JavaDatabaseOpener(log) - - suspend fun getDatabase(): Database { - val dbFile = fileOpener.openUserFile("test.sqlite3") - if (dbFile.exists()) dbFile.delete() - val db = databaseOpener.open(dbFile) - db.migrateTo(LOOP_DATABASE_VERSION, fileOpener, log) - return db - } - - @Test - fun testFiles() = runBlocking { - FilesTest(fileOpener).testLines() - } - - @Test - fun testDatabase() = runBlocking { - DatabaseTest(getDatabase()).testUsage() - } - - @Test - fun testCheckmarkRepository() = runBlocking { - CheckmarkRepositoryTest(getDatabase()).testCRUD() - } - - @Test - fun testHabitRepository() = runBlocking { - HabitRepositoryTest(getDatabase()).testCRUD() - } - - @Test - fun testPreferencesRepository() = runBlocking { - PreferencesRepositoryTest(getDatabase()).testUsage() - } -} \ No newline at end of file +/** + * Workaround until Kotlin adds support for testing suspend functions + * https://youtrack.jetbrains.com/issue/KT-22228 + */ +actual fun asyncTest(block: suspend () -> Unit) = runBlocking { block() } diff --git a/ios/Application/AppDelegate.swift b/ios/Application/AppDelegate.swift index 74c0c8a26..7aae707a8 100644 --- a/ios/Application/AppDelegate.swift +++ b/ios/Application/AppDelegate.swift @@ -34,7 +34,7 @@ import UIKit fileOpener: IosFileOpener(), localeHelper: IosLocaleHelper(NSLocale.preferredLanguages), log: log, - crCtx: UIDispatcher()) + scope: UIDispatcher()) backend?.observable.addListener(listener: self) backend?.doInit()