chore(clean up): remove unused imports, unnecessary object impls, concurrency/coroutine issues, trailing commas, etc.
This commit is contained in:
+11
-14
@@ -31,20 +31,22 @@ class DefaultInferenceRouterTest {
|
||||
override fun register(provider: InferenceProvider) = Unit
|
||||
override fun resolve(capability: ModelCapability) =
|
||||
providers.filter { p -> p.capabilities().any { it.capability == capability } }
|
||||
|
||||
override fun listAll() = providers.toList()
|
||||
override suspend fun healthCheckAll() = providers.associate { it.id to ProviderHealth.Healthy }
|
||||
}
|
||||
|
||||
private fun firstStrategy(): RoutingStrategy =
|
||||
object : RoutingStrategy {
|
||||
override fun select(candidates: List<InferenceProvider>, requiredCapabilities: Set<ModelCapability>) =
|
||||
candidates.firstOrNull() ?: throw NoEligibleProviderException(StageId("?"), emptySet())
|
||||
RoutingStrategy { candidates, _ ->
|
||||
candidates.firstOrNull() ?: throw NoEligibleProviderException(StageId("?"), emptySet())
|
||||
}
|
||||
|
||||
private fun throwingStrategy(): RoutingStrategy =
|
||||
object : RoutingStrategy {
|
||||
override fun select(candidates: List<InferenceProvider>, requiredCapabilities: Set<ModelCapability>) =
|
||||
throw NoEligibleProviderException(StageId("?"), requiredCapabilities)
|
||||
RoutingStrategy { _, requiredCapabilities ->
|
||||
throw NoEligibleProviderException(
|
||||
StageId("?"),
|
||||
requiredCapabilities,
|
||||
)
|
||||
}
|
||||
|
||||
// ── capability matching ───────────────────────────────────────────────────
|
||||
@@ -60,14 +62,9 @@ class DefaultInferenceRouterTest {
|
||||
fun `deduplicates providers that satisfy multiple required capabilities`(): Unit = runBlocking {
|
||||
val p = provider("a", ModelCapability.General, ModelCapability.Coding)
|
||||
val selected = mutableListOf<InferenceProvider>()
|
||||
val captureStrategy = object : RoutingStrategy {
|
||||
override fun select(
|
||||
candidates: List<InferenceProvider>,
|
||||
requiredCapabilities: Set<ModelCapability>,
|
||||
): InferenceProvider {
|
||||
selected.addAll(candidates)
|
||||
return candidates.first()
|
||||
}
|
||||
val captureStrategy = RoutingStrategy { candidates, _ ->
|
||||
selected.addAll(candidates)
|
||||
candidates.first()
|
||||
}
|
||||
val router = DefaultInferenceRouter(
|
||||
registryOf(p),
|
||||
|
||||
+3
-4
@@ -7,7 +7,6 @@ import com.correx.core.events.types.SessionId
|
||||
import com.correx.testing.contracts.utils.ConcurrencyRunner
|
||||
import com.correx.testing.fixtures.EventFixtures
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.yield
|
||||
@@ -39,7 +38,7 @@ abstract class EventStoreContractTest {
|
||||
|
||||
store.append(e)
|
||||
assertThrows<Exception> {
|
||||
runBlocking { store.append(e) }
|
||||
store.append(e)
|
||||
}
|
||||
Assertions.assertEquals(1, store.read(SessionId("s1")).size)
|
||||
}
|
||||
@@ -75,7 +74,7 @@ abstract class EventStoreContractTest {
|
||||
ConcurrencyRunner.run(20, 100) { t, i ->
|
||||
runBlocking {
|
||||
store.append(
|
||||
EventFixtures.newEvent(EventId("e-$i-$t"), SessionId("s1"))
|
||||
EventFixtures.newEvent(EventId("e-$i-$t"), SessionId("s1")),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -152,7 +151,7 @@ abstract class EventStoreContractTest {
|
||||
store.append(EventFixtures.newEvent(EventId("a-$t-$i"), SessionId("s1")))
|
||||
} else {
|
||||
store.appendAll(
|
||||
listOf(EventFixtures.newEvent(EventId("b-$t-$i"), SessionId("s1")))
|
||||
listOf(EventFixtures.newEvent(EventId("b-$t-$i"), SessionId("s1"))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user