Skip to content

Commit f684d87

Browse files
committed
test: Improve database cleanup in JVM UI tests
- Update `AbstractNavigationTest` and `DesktopUiTests` to properly delete SQLite auxiliary files (`-wal`, `-shm`, and `-journal`) alongside the main database file during test setup. - Refactor the deletion logic in `AbstractNavigationTest` to use a more idiomatic Kotlin sequence for file operations.
1 parent bc51f17 commit f684d87

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

app/desktop/src/jvmTest/kotlin/com/softartdev/notedelight/ui/DesktopUiTests.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class DesktopUiTests : AbstractJvmUiTests() {
5454
}
5555
val safeRepo: SafeRepo = get(SafeRepo::class.java)
5656
safeRepo.closeDatabase()
57-
File(safeRepo.dbPath).takeIf(File::exists)?.delete()
57+
for (suffix: String in arrayOf("", "-wal", "-shm", "-journal")) {
58+
File(safeRepo.dbPath + suffix).delete()
59+
}
5860
safeRepo.buildDbIfNeed()
5961
val noteDAO: NoteDAO = get(NoteDAO::class.java)
6062
noteDAO.deleteAll()

ui/test-jvm/src/main/kotlin/com/softartdev/notedelight/ui/AbstractNavigationTest.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ abstract class AbstractNavigationTest {
6262
}
6363
val safeRepo: SafeRepo = KoinJavaComponent.get(SafeRepo::class.java)
6464
safeRepo.closeDatabase()
65-
File(safeRepo.dbPath).takeIf(File::exists)?.delete()
65+
sequenceOf("", "-wal", "-shm", "-journal")
66+
.map(safeRepo.dbPath::plus)
67+
.map(::File)
68+
.filter(File::exists)
69+
.forEach(File::delete)
6670
safeRepo.buildDbIfNeed()
6771
val noteDAO: NoteDAO = KoinJavaComponent.get(NoteDAO::class.java)
6872
noteDAO.deleteAll()
@@ -119,4 +123,4 @@ abstract class AbstractNavigationTest {
119123
composeTestRule.awaitIdle()
120124
assertEquals(5, navController.currentBackStack.value.size)
121125
}
122-
}
126+
}

0 commit comments

Comments
 (0)