test: fix test for redis

This commit is contained in:
2025-04-12 23:23:23 +02:00
parent d394fca3f9
commit 4086a21dcb
3 changed files with 61 additions and 50 deletions

View File

@@ -8,6 +8,7 @@ import eventDemo.business.event.event.NewPlayerEvent
import eventDemo.business.event.event.PlayerReadyEvent 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.continually
import io.kotest.assertions.nondeterministic.eventually import io.kotest.assertions.nondeterministic.eventually
import io.kotest.assertions.nondeterministic.eventuallyConfig import io.kotest.assertions.nondeterministic.eventuallyConfig
import io.kotest.core.spec.style.FunSpec import io.kotest.core.spec.style.FunSpec
@@ -65,6 +66,7 @@ class GameListRouteTest :
interval = 300.milliseconds interval = 300.milliseconds
}, },
) { ) {
continually(1.seconds) {
httpClient() httpClient()
.get("/games") { .get("/games") {
withAuth(player1) withAuth(player1)
@@ -81,6 +83,7 @@ class GameListRouteTest :
} }
} }
} }
}
test("/games return a game with status IS_STARTED") { test("/games return a game with status IS_STARTED") {
val gameId = GameId() val gameId = GameId()
@@ -103,6 +106,7 @@ class GameListRouteTest :
} }
} }
}) { }) {
eventually(1.seconds) {
httpClient() httpClient()
.get("/games") { .get("/games") {
withAuth(player1) withAuth(player1)
@@ -119,4 +123,5 @@ class GameListRouteTest :
} }
} }
} }
}
}) })

View File

@@ -12,6 +12,7 @@ import eventDemo.business.event.event.disableShuffleDeck
import eventDemo.business.event.projection.gameState.GameState import eventDemo.business.event.projection.gameState.GameState
import eventDemo.business.event.projection.gameState.GameStateRepository import eventDemo.business.event.projection.gameState.GameStateRepository
import eventDemo.testApplicationWithConfig import eventDemo.testApplicationWithConfig
import io.kotest.assertions.nondeterministic.eventually
import io.kotest.core.spec.style.FunSpec import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.collections.shouldHaveSize import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.equals.shouldBeEqual import io.kotest.matchers.equals.shouldBeEqual
@@ -26,6 +27,7 @@ import kotlinx.coroutines.runBlocking
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertIs import kotlin.test.assertIs
import kotlin.test.assertNotNull import kotlin.test.assertNotNull
import kotlin.time.Duration.Companion.seconds
class GameStateRouteTest : class GameStateRouteTest :
FunSpec({ FunSpec({
@@ -92,6 +94,7 @@ class GameStateRouteTest :
delay(100) delay(100)
} }
}) { }) {
eventually(1.seconds) {
httpClient() httpClient()
.get("/games/$gameId/state") { .get("/games/$gameId/state") {
withAuth(player1) withAuth(player1)
@@ -111,6 +114,7 @@ class GameStateRouteTest :
} }
} }
} }
}
test("""The route "/games/{id}/card/last" should return the last card played of the game""") { test("""The route "/games/{id}/card/last" should return the last card played of the game""") {
val gameId = GameId() val gameId = GameId()
@@ -155,6 +159,7 @@ class GameStateRouteTest :
delay(100) delay(100)
} }
}) { }) {
eventually(1.seconds) {
httpClient() httpClient()
.get("/games/$gameId/card/last") { .get("/games/$gameId/card/last") {
withAuth(player1) withAuth(player1)
@@ -165,4 +170,5 @@ class GameStateRouteTest :
} }
} }
} }
}
}) })

View File

@@ -173,7 +173,7 @@ class GameStateRepositoryTest :
lastEventVersion shouldBeEqual 200 lastEventVersion shouldBeEqual 200
players shouldHaveSize 200 players shouldHaveSize 200
} }
repo.count(aggregateId) shouldBe 39 repo.count(aggregateId) shouldBe 21
} }
} }
} }