Skip to content

Commit 55cdbec

Browse files
jamesarichCopilot
andcommitted
fix(database): use BundledSQLiteDriver for consistent test behavior
- Use BundledSQLiteDriver in DatabaseBuilder for deterministic SQLite behavior across test environments - Simplify DiscoveryMigrationTest to use context-free inMemoryDatabaseBuilder with BundledSQLiteDriver (removes ApplicationProvider dependency) - Update migration doc comment to reflect version 39→40 path Found during release/2.8.0 integration testing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 80d3a1a commit 55cdbec

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

core/database/src/androidHostTest/kotlin/org/meshtastic/core/database/dao/DiscoveryMigrationTest.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.meshtastic.core.database.dao
1818

1919
import androidx.room3.Room
20-
import androidx.test.core.app.ApplicationProvider
20+
import androidx.sqlite.driver.bundled.BundledSQLiteDriver
2121
import androidx.test.ext.junit.runners.AndroidJUnit4
2222
import kotlinx.coroutines.flow.first
2323
import kotlinx.coroutines.test.runTest
@@ -39,7 +39,7 @@ import kotlin.test.assertTrue
3939
/**
4040
* Migration coverage for discovery tables (D011).
4141
*
42-
* Verifies that the discovery schema (version 38→39 auto-migration) creates the expected tables, supports CRUD
42+
* Verifies that the discovery schema (version 39→40 auto-migration) creates the expected tables, supports CRUD
4343
* operations, enforces foreign key cascade behavior, and respects column defaults.
4444
*/
4545
@RunWith(AndroidJUnit4::class)
@@ -51,12 +51,9 @@ class DiscoveryMigrationTest {
5151

5252
@Before
5353
fun createDb() {
54-
val context = ApplicationProvider.getApplicationContext<android.content.Context>()
5554
database =
56-
Room.inMemoryDatabaseBuilder<MeshtasticDatabase>(
57-
context = context,
58-
factory = { MeshtasticDatabaseConstructor.initialize() },
59-
)
55+
Room.inMemoryDatabaseBuilder<MeshtasticDatabase>(factory = { MeshtasticDatabaseConstructor.initialize() })
56+
.setDriver(BundledSQLiteDriver())
6057
.build()
6158
discoveryDao = database.discoveryDao()
6259
}

core/database/src/androidMain/kotlin/org/meshtastic/core/database/DatabaseBuilder.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.datastore.preferences.core.emptyPreferences
2424
import androidx.datastore.preferences.preferencesDataStoreFile
2525
import androidx.room3.Room
2626
import androidx.room3.RoomDatabase
27+
import androidx.sqlite.driver.bundled.BundledSQLiteDriver
2728
import okio.FileSystem
2829
import okio.Path
2930
import okio.Path.Companion.toPath
@@ -39,6 +40,7 @@ actual fun getDatabaseBuilder(dbName: String): RoomDatabase.Builder<MeshtasticDa
3940
name = dbFile.absolutePath,
4041
factory = { MeshtasticDatabaseConstructor.initialize() },
4142
)
43+
.setDriver(BundledSQLiteDriver())
4244
.configureCommon()
4345
}
4446

0 commit comments

Comments
 (0)