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

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

View File

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