Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

When running iOS unit tests the database is not created and exception is received #40

Open
timbob2000 opened this issue Jul 21, 2021 · 1 comment

Comments

@timbob2000
Copy link

Steps to reproduce:

  1. Create a project and apply gradle configuration as specified in "examples" found on the interweb
  2. Write Unit test in iosTest source set

class DataProviderTests {

    @Test
    fun `Test basic open on ios`() {
        DB.inDir(NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0] as String)
            .open("myinstance", TypeTable {
                root<MyTestEntity>()
            }, KotlinxSerializer())
    }
}

@Serializable
class MyTestEntity(override val id: String, val name: String) : Metadata

  1. Run unit tests via gradle
./gradlew check

Expected results

The database should be created as it is specified in the documentation
image

Actual result: Exception is thrown:


org.kodein.db.leveldb.LevelDBException: NotFound: /Users/tosborn/Library/Developer/CoreSimulator/Devices/6DF6DEF7-08AF-4D96-8F75-3213776E5A88/data/Documents/myinstance/LOCK: No such file or directory
org.kodein.db.leveldb.LevelDBException: NotFound: /Users/tosborn/Library/Developer/CoreSimulator/Devices/6DF6DEF7-08AF-4D96-8F75-3213776E5A88/data/Documents/myinstance/LOCK: No such file or directory
	at kotlin.Throwable#<init>(/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/Throwable.kt:23)
	at kotlin.Exception#<init>(/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/Exceptions.kt:23)
	at org.kodein.db.leveldb.LevelDBException#<init>(/Users/runner/work/Kodein-DB/Kodein-DB/ldb/kodein-leveldb-api/src/commonMain/kotlin/org/kodein/db/leveldb/LevelDBException.kt:6)
	at org.kodein.db.leveldb.native.LevelDBNative.Factory#open(/Users/runner/work/Kodein-DB/Kodein-DB/ldb/kodein-leveldb/src/allNativeMain/kotlin/org/kodein/db/leveldb/native/LevelDBNative.kt:111)
	at org.kodein.db.impl.kv.AbstractKeyValueDBFactory#open(/Users/runner/work/Kodein-DB/Kodein-DB/kdb/kodein-db/src/commonMain/kotlin/org/kodein/db/impl/kv/AbstractKeyValueDBFactory.kt:20)
	at org.kodein.db.impl.data.AbstractDataDBFactory#open(/Users/runner/work/Kodein-DB/Kodein-DB/kdb/kodein-db/src/commonMain/kotlin/org/kodein/db/impl/data/AbstractDataDBFactory.kt:20)
	at org.kodein.db.impl.model.AbstractModelDBFactory#open(/Users/runner/work/Kodein-DB/Kodein-DB/kdb/kodein-db/src/commonMain/kotlin/org/kodein/db/impl/model/AbstractModelDBFactory.kt:29)
	at org.kodein.db.impl.AbstractDBFactory#open(/Users/runner/work/Kodein-DB/Kodein-DB/kdb/kodein-db/src/commonMain/kotlin/org/kodein/db/impl/AbstractDBFactory.kt:25)
	at org.kodein.db.DBFactory.Based#open(/Users/runner/work/Kodein-DB/Kodein-DB/kdb/kodein-db-api/src/commonMain/kotlin/org/kodein/db/DBFactory.kt:8)
	at com.insulet.cordibus.platform.common.DataProviderTests#Test(/Users/tosborn/InsuletWorkspace/platform-core/platform-core/src/iosTest/kotlin/com/insulet/cordibus/platform/common/DataProviderTest.kt:18)
	at com.insulet.cordibus.platform.common.$DataProviderTests$test$0.$Test(/Users/tosborn/InsuletWorkspace/platform-core/platform-core/src/iosTest/kotlin/com/insulet/cordibus/platform/common/DataProviderTest.kt:17)
	at com.insulet.cordibus.platform.common.$DataProviderTests$test$0.$Test(/Users/tosborn/InsuletWorkspace/platform-core/platform-core/src/iosTest/kotlin/com/insulet/cordibus/platform/common/DataProviderTest.kt:17)
	at kotlin.native.internal.test.BaseClassSuite.TestCase#run(/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/internal/test/TestSuite.kt:85)
	at kotlin.native.internal.test.TestRunner.run#internal(/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/internal/test/TestRunner.kt:245)
	at kotlin.native.internal.test.TestRunner.runIteration#internal(/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/internal/test/TestRunner.kt:271)
	at kotlin.native.internal.test.TestRunner#run(/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/internal/test/TestRunner.kt:286)
	at kotlin.native.internal.test#testLauncherEntryPoint(/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt:22)
	at kotlin.native.internal.test#main(/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt:26)
	at <global>.Konan_start(/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt:25)
	at <global>.Init_and_run_start(Unknown Source)
	at <global>.start(Unknown Source)
	at <global>.0x0(Unknown Source)
@SalomonBrys
Copy link
Member

Does this happen at all tests?
This error may happen if you try to open a database that you did not close properly, so is it possible that your first test runs, and that your second test fails with this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants