Skip to content

Commit

Permalink
Add more tests to linux target (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
illarionov authored Aug 25, 2024
1 parent 8de9c0f commit e6e77b1
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 3 deletions.
5 changes: 2 additions & 3 deletions sqlite-driver/src/jvmTest/kotlin/base/JvmDatabaseFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.sqlite.SQLiteDriver
import ru.pixnews.wasm.sqlite.driver.test.base.room.UserDatabaseSuspend
import ru.pixnews.wasm.sqlite.driver.test.base.room.UserDatabaseSuspend_Impl
import ru.pixnews.wasm.sqlite.driver.test.base.tests.room.UserDatabaseTests.UserDatabaseFactory
import kotlin.coroutines.CoroutineContext

Expand All @@ -21,9 +20,9 @@ internal object JvmDatabaseFactory : UserDatabaseFactory {
queryCoroutineContext: CoroutineContext,
): UserDatabaseSuspend {
val builder = if (databaseName != null) {
Room.databaseBuilder(databaseName, ::UserDatabaseSuspend_Impl)
Room.databaseBuilder<UserDatabaseSuspend>(databaseName)
} else {
Room.inMemoryDatabaseBuilder(::UserDatabaseSuspend_Impl)
Room.inMemoryDatabaseBuilder<UserDatabaseSuspend>()
}
return builder
.setJournalMode(RoomDatabase.JournalMode.WRITE_AHEAD_LOGGING)
Expand Down
33 changes: 33 additions & 0 deletions sqlite-driver/src/linuxTest/kotlin/base/LinuxDatabaseFactory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024, the wasm-sqlite-open-helper project authors and contributors. Please see the AUTHORS file
* for details. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
* SPDX-License-Identifier: Apache-2.0
*/

package ru.pixnews.wasm.sqlite.driver.base

import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.sqlite.SQLiteDriver
import ru.pixnews.wasm.sqlite.driver.test.base.room.UserDatabaseSuspend
import ru.pixnews.wasm.sqlite.driver.test.base.tests.room.UserDatabaseTests.UserDatabaseFactory
import kotlin.coroutines.CoroutineContext

class LinuxDatabaseFactory : UserDatabaseFactory {
override fun create(
driver: SQLiteDriver,
databaseName: String?,
queryCoroutineContext: CoroutineContext,
): UserDatabaseSuspend {
val builder = if (databaseName != null) {
Room.databaseBuilder<UserDatabaseSuspend>(databaseName)
} else {
Room.inMemoryDatabaseBuilder<UserDatabaseSuspend>()
}
return builder
.setJournalMode(RoomDatabase.JournalMode.WRITE_AHEAD_LOGGING)
.setDriver(driver)
.setQueryCoroutineContext(queryCoroutineContext)
.build()
}
}
33 changes: 33 additions & 0 deletions sqlite-driver/src/linuxTest/kotlin/chasm/ChasmBasicRoomTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024, the wasm-sqlite-open-helper project authors and contributors. Please see the AUTHORS file
* for details. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
* SPDX-License-Identifier: Apache-2.0
*/

package ru.pixnews.wasm.sqlite.driver.chasm

import ru.pixnews.wasm.sqlite.driver.WasmSQLiteDriver
import ru.pixnews.wasm.sqlite.driver.base.LinuxDatabaseFactory
import ru.pixnews.wasm.sqlite.driver.test.base.tests.room.AbstractBasicRoomTest
import ru.pixnews.wasm.sqlite.test.utils.TempFolder
import kotlin.test.AfterTest
import kotlin.test.BeforeTest

class ChasmBasicRoomTest : AbstractBasicRoomTest<WasmSQLiteDriver<*>>(
driverFactory = ChasmSqliteDriverFactory,
databaseFactory = LinuxDatabaseFactory(),
) {
private lateinit var tempDir: TempFolder

@BeforeTest
fun setupTempDir() {
tempDir = TempFolder.create()
}

@AfterTest
fun cleanupTempDir() {
tempDir.delete()
}

override fun fileInTempDir(databaseName: String): String = tempDir.resolve(databaseName)
}
31 changes: 31 additions & 0 deletions sqlite-driver/src/linuxTest/kotlin/chasm/ChasmIcuCollationTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2024, the wasm-sqlite-open-helper project authors and contributors. Please see the AUTHORS file
* for details. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
* SPDX-License-Identifier: Apache-2.0
*/

package ru.pixnews.wasm.sqlite.driver.chasm

import ru.pixnews.wasm.sqlite.driver.WasmSQLiteDriver
import ru.pixnews.wasm.sqlite.driver.test.base.tests.AbstractIcuCollationTest
import ru.pixnews.wasm.sqlite.test.utils.TempFolder
import kotlin.test.AfterTest
import kotlin.test.BeforeTest

class ChasmIcuCollationTest : AbstractIcuCollationTest<WasmSQLiteDriver<*>>(
driverCreator = ChasmSqliteDriverFactory,
) {
private lateinit var tempDir: TempFolder

@BeforeTest
fun setupTempDir() {
tempDir = TempFolder.create()
}

@AfterTest
fun cleanupTempDir() {
tempDir.delete()
}

override fun fileInTempDir(databaseName: String): String = tempDir.resolve(databaseName)
}
39 changes: 39 additions & 0 deletions sqlite-driver/src/linuxTest/kotlin/chasm/ChasmTimeFunctionsTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2024, the wasm-sqlite-open-helper project authors and contributors. Please see the AUTHORS file
* for details. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
* SPDX-License-Identifier: Apache-2.0
*/

package ru.pixnews.wasm.sqlite.driver.chasm

import ru.pixnews.wasm.sqlite.driver.WasmSQLiteDriver
import ru.pixnews.wasm.sqlite.driver.test.base.tests.AbstractTimeFunctionsTest
import ru.pixnews.wasm.sqlite.test.utils.TempFolder
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Ignore
import kotlin.test.Test

class ChasmTimeFunctionsTest : AbstractTimeFunctionsTest<WasmSQLiteDriver<*>>(
driverCreator = ChasmSqliteDriverFactory,
) {
private lateinit var tempDir: TempFolder

@BeforeTest
fun setupTempDir() {
tempDir = TempFolder.create()
}

@AfterTest
fun cleanupTempDir() {
tempDir.delete()
}

override fun fileInTempDir(databaseName: String): String = tempDir.resolve(databaseName)

@Test
@Ignore // TODO
override fun localtime_modifier_should_work() {
super.localtime_modifier_should_work()
}
}

0 comments on commit e6e77b1

Please sign in to comment.