feat: parallelize BaseDBTest forEachDB using coroutines
Each EventStore uses an independent in-memory SQLite database, so tests can safely run concurrently. This launches all 16 DB configurations in parallel via coroutines on Dispatchers.Default instead of running them sequentially. https://claude.ai/code/session_01TQRzVTAXBVWRGstcsapA5F
This commit is contained in:
+13
-7
@@ -21,6 +21,9 @@
|
||||
package com.vitorpamplona.quartz.nip01Core.store.sqlite
|
||||
|
||||
import com.vitorpamplona.quartz.utils.Secp256k1Instance
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.test.AfterTest
|
||||
import kotlin.test.BeforeTest
|
||||
|
||||
@@ -72,12 +75,15 @@ open class BaseDBTest {
|
||||
dbs.forEach { it.value.close() }
|
||||
}
|
||||
|
||||
fun forEachDB(action: (EventStore) -> Unit) {
|
||||
dbs.forEach {
|
||||
println("--------------------")
|
||||
println(it.key)
|
||||
println("--------------------")
|
||||
action(it.value)
|
||||
fun forEachDB(action: (EventStore) -> Unit) =
|
||||
runBlocking {
|
||||
dbs.forEach { (key, value) ->
|
||||
launch(Dispatchers.Default) {
|
||||
println("--------------------")
|
||||
println(key)
|
||||
println("--------------------")
|
||||
action(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user