From cb3ec3f96cc6fdd7b03b5e298bfc85e3727f4c96 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Tue, 8 Apr 2025 00:44:11 +0200 Subject: [PATCH] Fix tests --- .../configuration/business/ConfigureGameListener.kt | 4 ++-- .../adapter/interfaceLayer/query/GameListRouteTest.kt | 9 ++++++++- .../adapter/interfaceLayer/query/GameSimulationTest.kt | 6 +++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/eventDemo/configuration/business/ConfigureGameListener.kt b/src/main/kotlin/eventDemo/configuration/business/ConfigureGameListener.kt index e1f1db9..50816ca 100644 --- a/src/main/kotlin/eventDemo/configuration/business/ConfigureGameListener.kt +++ b/src/main/kotlin/eventDemo/configuration/business/ConfigureGameListener.kt @@ -7,7 +7,7 @@ import eventDemo.business.event.projection.projectionListener.ReactionListener import org.koin.core.Koin fun Koin.configureGameListener() { - get() + get() .subscribeToBus(get()) get() @@ -16,6 +16,6 @@ fun Koin.configureGameListener() { get() .subscribeToBus(get(), get()) - get() + get() .subscribeToBus(get()) } diff --git a/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameListRouteTest.kt b/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameListRouteTest.kt index 88568ff..f1c50f2 100644 --- a/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameListRouteTest.kt +++ b/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameListRouteTest.kt @@ -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) diff --git a/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameSimulationTest.kt b/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameSimulationTest.kt index 09d8523..f2d9743 100644 --- a/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameSimulationTest.kt +++ b/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameSimulationTest.kt @@ -82,9 +82,6 @@ class GameSimulationTest : assertIs(it).commandId shouldBeEqual sendCommand.id } } - channelNotification1.receive().let { - assertIs(it).player shouldBeEqual player2 - } val player1Hand = channelNotification1.receive().let { assertIs(it).hand shouldHaveSize 7 @@ -95,6 +92,9 @@ class GameSimulationTest : player shouldBeEqual player1 } } + channelNotification1.receive().let { + assertIs(it).player shouldBeEqual player2 + } IWantToPlayCardCommand(IWantToPlayCardCommand.Payload(gameId, player1, player1Hand.first())).also { sendCommand -> channelCommand1.send(sendCommand)