fix testApplicationWithConfig

This commit is contained in:
2025-04-05 04:44:48 +02:00
parent e1529ee52c
commit fd954e631d
7 changed files with 60 additions and 56 deletions

View File

@@ -6,7 +6,7 @@ import eventDemo.business.event.GameEventHandler
import eventDemo.business.event.event.NewPlayerEvent
import eventDemo.business.event.projection.gameState.GameState
import eventDemo.business.event.projection.gameState.GameStateRepository
import eventDemo.testApplicationWithConfig
import eventDemo.testKoinApplicationWithConfig
import io.kotest.assertions.nondeterministic.eventually
import io.kotest.assertions.nondeterministic.eventuallyConfig
import io.kotest.core.spec.style.FunSpec
@@ -29,9 +29,9 @@ class GameStateRepositoryTest :
test("GameStateRepository should build the projection when a new event occurs") {
val aggregateId = GameId()
testApplicationWithConfig { koin ->
val repo = koin.get<GameStateRepository>()
val eventHandler = koin.get<GameEventHandler>()
testKoinApplicationWithConfig {
val repo = get<GameStateRepository>()
val eventHandler = get<GameEventHandler>()
eventHandler
.handle(aggregateId) { NewPlayerEvent(aggregateId = aggregateId, player = player1, version = it) }
.also { event ->
@@ -50,10 +50,10 @@ class GameStateRepositoryTest :
test("get should build the last version of the state") {
val aggregateId = GameId()
testApplicationWithConfig { koin ->
val repo = koin.get<GameStateRepository>()
val eventHandler = koin.get<GameEventHandler>()
val projectionBus = koin.get<GameProjectionBus>()
testKoinApplicationWithConfig {
val repo = get<GameStateRepository>()
val eventHandler = get<GameEventHandler>()
val projectionBus = get<GameProjectionBus>()
var state: GameState? = null
projectionBus.subscribe {
@@ -86,9 +86,9 @@ class GameStateRepositoryTest :
test("getUntil should build the state until the event") {
repeat(10) {
val aggregateId = GameId()
testApplicationWithConfig { koin ->
val repo = koin.get<GameStateRepository>()
val eventHandler = koin.get<GameEventHandler>()
testKoinApplicationWithConfig {
val repo = get<GameStateRepository>()
val eventHandler = get<GameEventHandler>()
val event1 =
eventHandler
@@ -115,9 +115,9 @@ class GameStateRepositoryTest :
test("getUntil should be concurrently secure") {
val aggregateId = GameId()
testApplicationWithConfig { koin ->
val repo = koin.get<GameStateRepository>()
val eventHandler = koin.get<GameEventHandler>()
testKoinApplicationWithConfig {
val repo = get<GameStateRepository>()
val eventHandler = get<GameEventHandler>()
(1..10)
.map { r ->