Merge pull request #4602

* refactor(test): Introduce MeshTestApplication for robust testing
This commit is contained in:
James Rich 2026-02-20 11:25:11 -06:00 committed by GitHub
parent f75622002f
commit ac5a1714e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 77 additions and 2 deletions

View file

@ -24,6 +24,7 @@ import androidx.room.RoomDatabase
import co.touchlab.kermit.Logger
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
@ -209,6 +210,14 @@ class DatabaseManager @Inject constructor(private val app: Application, private
}
prefs.edit().putBoolean(DatabaseConstants.LEGACY_DB_CLEANED_KEY, true).apply()
}
/** Closes all open databases and cancels background work. */
fun close() {
managerScope.cancel()
dbCache.values.forEach { it.close() }
dbCache.clear()
_currentDb.value = null
}
}
object DatabaseConstants {