Fix tests

This commit is contained in:
2025-04-08 00:44:11 +02:00
parent 080ea1245d
commit cb3ec3f96c
3 changed files with 13 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ import eventDemo.business.event.projection.projectionListener.ReactionListener
import org.koin.core.Koin import org.koin.core.Koin
fun Koin.configureGameListener() { fun Koin.configureGameListener() {
get<ReactionListener>() get<GameCommandHandler>()
.subscribeToBus(get()) .subscribeToBus(get())
get<GameStateRepositoryInMemory>() get<GameStateRepositoryInMemory>()
@@ -16,6 +16,6 @@ fun Koin.configureGameListener() {
get<GameListRepositoryInMemory>() get<GameListRepositoryInMemory>()
.subscribeToBus(get(), get()) .subscribeToBus(get(), get())
get<GameCommandHandler>() get<ReactionListener>()
.subscribeToBus(get()) .subscribeToBus(get())
} }

View File

@@ -9,6 +9,7 @@ import eventDemo.business.event.event.PlayerReadyEvent
import eventDemo.business.event.projection.gameList.GameList import eventDemo.business.event.projection.gameList.GameList
import eventDemo.testApplicationWithConfig import eventDemo.testApplicationWithConfig
import io.kotest.assertions.nondeterministic.eventually import io.kotest.assertions.nondeterministic.eventually
import io.kotest.assertions.nondeterministic.eventuallyConfig
import io.kotest.core.spec.style.FunSpec import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.collections.shouldContain import io.kotest.matchers.collections.shouldContain
import io.kotest.matchers.collections.shouldHaveSize import io.kotest.matchers.collections.shouldHaveSize
@@ -22,6 +23,7 @@ import io.ktor.http.HttpStatusCode
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertTrue import kotlin.test.assertTrue
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds import kotlin.time.Duration.Companion.seconds
class GameListRouteTest : class GameListRouteTest :
@@ -57,7 +59,12 @@ class GameListRouteTest :
}, },
) { ) {
// Wait until the projection is created // Wait until the projection is created
eventually(3.seconds) { eventually(
eventuallyConfig {
duration = 3.seconds
interval = 300.milliseconds
},
) {
httpClient() httpClient()
.get("/games") { .get("/games") {
withAuth(player1) withAuth(player1)

View File

@@ -82,9 +82,6 @@ class GameSimulationTest :
assertIs<CommandSuccessNotification>(it).commandId shouldBeEqual sendCommand.id assertIs<CommandSuccessNotification>(it).commandId shouldBeEqual sendCommand.id
} }
} }
channelNotification1.receive().let {
assertIs<PlayerWasReadyNotification>(it).player shouldBeEqual player2
}
val player1Hand = val player1Hand =
channelNotification1.receive().let { channelNotification1.receive().let {
assertIs<TheGameWasStartedNotification>(it).hand shouldHaveSize 7 assertIs<TheGameWasStartedNotification>(it).hand shouldHaveSize 7
@@ -95,6 +92,9 @@ class GameSimulationTest :
player shouldBeEqual player1 player shouldBeEqual player1
} }
} }
channelNotification1.receive().let {
assertIs<PlayerWasReadyNotification>(it).player shouldBeEqual player2
}
IWantToPlayCardCommand(IWantToPlayCardCommand.Payload(gameId, player1, player1Hand.first())).also { sendCommand -> IWantToPlayCardCommand(IWantToPlayCardCommand.Payload(gameId, player1, player1Hand.first())).also { sendCommand ->
channelCommand1.send(sendCommand) channelCommand1.send(sendCommand)