Skip to content

Commit 1dfbb48

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "Changing SQLiteDriver API to take in a fileName at open()." into androidx-main
2 parents b8a11c5 + 1f3895a commit 1dfbb48

49 files changed

Lines changed: 348 additions & 137 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/migration/MigrationKotlinTest.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ class MigrationKotlinTest {
325325
val dbFile = instrumentation.targetContext.getDatabasePath("test.db")
326326
val driverHelper = MigrationTestHelper(
327327
instrumentation = instrumentation,
328-
driver = AndroidSQLiteDriver(dbFile.path),
328+
fileName = dbFile.path,
329+
driver = AndroidSQLiteDriver(),
329330
databaseClass = MigrationDbKotlin::class
330331
)
331332
assertThrows<IllegalStateException> {

‎room/integration-tests/multiplatformtestapp/src/androidInstrumentedTest/kotlin/androidx/room/integration/multiplatformtestapp/test/AutoMigrationTest.kt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ import org.junit.Rule
3434
class AutoMigrationTest : BaseAutoMigrationTest() {
3535
private val instrumentation = InstrumentationRegistry.getInstrumentation()
3636
private val file = instrumentation.targetContext.getDatabasePath("test.db")
37-
private val driver: SQLiteDriver = BundledSQLiteDriver(file.path)
37+
private val driver: SQLiteDriver = BundledSQLiteDriver()
3838

3939
@get:Rule
4040
val migrationTestHelper = MigrationTestHelper(
4141
instrumentation = instrumentation,
4242
driver = driver,
43-
databaseClass = AutoMigrationDatabase::class
43+
databaseClass = AutoMigrationDatabase::class,
44+
fileName = file.path
4445
)
4546

4647
override fun getTestHelper() = migrationTestHelper

‎room/integration-tests/multiplatformtestapp/src/androidInstrumentedTest/kotlin/androidx/room/integration/multiplatformtestapp/test/BuilderTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class BuilderTest : BaseBuilderTest() {
3434
context = instrumentation.targetContext,
3535
name = file.path,
3636
factory = { SampleDatabase::class.instantiateImpl() }
37-
).setDriver(BundledSQLiteDriver(file.path))
37+
).setDriver(BundledSQLiteDriver())
3838
}
3939

4040
@BeforeTest

‎room/integration-tests/multiplatformtestapp/src/androidInstrumentedTest/kotlin/androidx/room/integration/multiplatformtestapp/test/InvalidationTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class InvalidationTest : BaseInvalidationTest() {
2727
override fun getRoomDatabase(): SampleDatabase {
2828
return Room.inMemoryDatabaseBuilder<SampleDatabase>(
2929
context = instrumentation.targetContext,
30-
).setDriver(BundledSQLiteDriver(":memory:"))
30+
).setDriver(BundledSQLiteDriver())
3131
.build()
3232
}
3333
}

‎room/integration-tests/multiplatformtestapp/src/androidInstrumentedTest/kotlin/androidx/room/integration/multiplatformtestapp/test/SimpleQueryTest.kt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ class SimpleQueryTest : BaseSimpleQueryTest() {
2626
private val instrumentation = InstrumentationRegistry.getInstrumentation()
2727

2828
override fun getRoomDatabase(): SampleDatabase {
29-
return Room.inMemoryDatabaseBuilder<SampleDatabase>(instrumentation.targetContext)
30-
.setDriver(BundledSQLiteDriver(":memory:"))
29+
return Room.inMemoryDatabaseBuilder<SampleDatabase>(
30+
context = instrumentation.targetContext
31+
).setDriver(BundledSQLiteDriver())
3132
.setQueryCoroutineContext(Dispatchers.IO)
3233
.build()
3334
}

‎room/integration-tests/multiplatformtestapp/src/jvmTest/kotlin/androidx/room/integration/multiplatformtestapp/test/AutoMigrationTest.kt‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,21 @@ import kotlin.io.path.createTempFile
2525
import org.junit.Rule
2626

2727
class AutoMigrationTest : BaseAutoMigrationTest() {
28-
private val tempFile = createTempFile("test.db").also { it.toFile().deleteOnExit() }
29-
private val driver: SQLiteDriver = BundledSQLiteDriver(tempFile.toString())
28+
private val tempFilePath = createTempFile("test.db").also { it.toFile().deleteOnExit() }
29+
private val driver: SQLiteDriver = BundledSQLiteDriver()
3030

3131
@get:Rule
3232
val migrationTestHelper = MigrationTestHelper(
3333
schemaDirectoryPath = Path("schemas-ksp"),
34+
databasePath = tempFilePath,
3435
driver = driver,
3536
databaseClass = AutoMigrationDatabase::class
3637
)
3738

3839
override fun getTestHelper() = migrationTestHelper
3940

4041
override fun getRoomDatabase(): AutoMigrationDatabase {
41-
return Room.databaseBuilder<AutoMigrationDatabase>(tempFile.toString())
42+
return Room.databaseBuilder<AutoMigrationDatabase>(tempFilePath.toString())
4243
.setDriver(driver).build()
4344
}
4445
}

‎room/integration-tests/multiplatformtestapp/src/jvmTest/kotlin/androidx/room/integration/multiplatformtestapp/test/BuilderTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ class BuilderTest : BaseBuilderTest() {
2525
override fun getRoomDatabaseBuilder(): RoomDatabase.Builder<SampleDatabase> {
2626
val tempFile = createTempFile("test.db").also { it.toFile().deleteOnExit() }
2727
return Room.databaseBuilder(tempFile.toString()) { SampleDatabase::class.instantiateImpl() }
28-
.setDriver(BundledSQLiteDriver(tempFile.toString()))
28+
.setDriver(BundledSQLiteDriver())
2929
}
3030
}

‎room/integration-tests/multiplatformtestapp/src/jvmTest/kotlin/androidx/room/integration/multiplatformtestapp/test/InvalidationTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class InvalidationTest : BaseInvalidationTest() {
2323

2424
override fun getRoomDatabase(): SampleDatabase {
2525
return Room.inMemoryDatabaseBuilder<SampleDatabase>()
26-
.setDriver(BundledSQLiteDriver(":memory:"))
26+
.setDriver(BundledSQLiteDriver())
2727
.build()
2828
}
2929
}

‎room/integration-tests/multiplatformtestapp/src/jvmTest/kotlin/androidx/room/integration/multiplatformtestapp/test/SimpleQueryTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SimpleQueryTest : BaseSimpleQueryTest() {
2424

2525
override fun getRoomDatabase(): SampleDatabase {
2626
return Room.inMemoryDatabaseBuilder<SampleDatabase>()
27-
.setDriver(BundledSQLiteDriver(":memory:"))
27+
.setDriver(BundledSQLiteDriver())
2828
.setQueryCoroutineContext(Dispatchers.IO)
2929
.build()
3030
}

‎room/integration-tests/multiplatformtestapp/src/nativeTest/kotlin/androidx/room/integration/multiplatformtestapp/test/AutoMigrationTest.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ import platform.posix.remove
2727

2828
class AutoMigrationTest : BaseAutoMigrationTest() {
2929
private val filename = "/tmp/test-${Random.nextInt()}.db"
30-
private val driver: SQLiteDriver = BundledSQLiteDriver(filename)
30+
private val driver: SQLiteDriver = BundledSQLiteDriver()
3131

3232
private val migrationTestHelper = MigrationTestHelper(
3333
schemaDirectoryPath = getSchemaDirectoryPath(),
34+
fileName = filename,
3435
driver = driver,
3536
databaseClass = AutoMigrationDatabase::class,
3637
databaseFactory = { AutoMigrationDatabase::class.instantiateImpl() }

0 commit comments

Comments
 (0)