fix testApplicationWithConfig
This commit is contained in:
@@ -44,15 +44,18 @@ class GameListRouteTest :
|
||||
}
|
||||
|
||||
test("/games return a game with status OPENING") {
|
||||
testApplicationWithConfig { koin ->
|
||||
val gameId = GameId()
|
||||
val player1 = Player(name = "Nikola")
|
||||
|
||||
val eventHandler = koin.get<GameEventHandler>()
|
||||
runBlocking {
|
||||
eventHandler.handle(gameId) { NewPlayerEvent(gameId, player1, it) }
|
||||
}
|
||||
|
||||
val gameId = GameId()
|
||||
val player1 = Player(name = "Nikola")
|
||||
testApplicationWithConfig(
|
||||
{
|
||||
runBlocking {
|
||||
get<GameEventHandler>()
|
||||
.handle(gameId) {
|
||||
NewPlayerEvent(gameId, player1, it)
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
// Wait until the projection is created
|
||||
eventually(3.seconds) {
|
||||
httpClient()
|
||||
@@ -73,11 +76,11 @@ class GameListRouteTest :
|
||||
}
|
||||
|
||||
test("/games return a game with status IS_STARTED") {
|
||||
testApplicationWithConfig { koin ->
|
||||
val gameId = GameId()
|
||||
val player1 = Player(name = "Nikola")
|
||||
val player2 = Player(name = "Einstein")
|
||||
val eventHandler = koin.get<GameEventHandler>()
|
||||
val gameId = GameId()
|
||||
val player1 = Player(name = "Nikola")
|
||||
val player2 = Player(name = "Einstein")
|
||||
testApplicationWithConfig({
|
||||
val eventHandler = get<GameEventHandler>()
|
||||
runBlocking {
|
||||
eventHandler.handle(gameId) { NewPlayerEvent(gameId, player1, it) }
|
||||
eventHandler.handle(gameId) { NewPlayerEvent(gameId, player2, it) }
|
||||
@@ -92,7 +95,7 @@ class GameListRouteTest :
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}) {
|
||||
httpClient()
|
||||
.get("/games") {
|
||||
withAuth(player1)
|
||||
|
||||
@@ -21,7 +21,6 @@ import eventDemo.business.notification.PlayerAsPlayACardNotification
|
||||
import eventDemo.business.notification.PlayerWasReadyNotification
|
||||
import eventDemo.business.notification.TheGameWasStartedNotification
|
||||
import eventDemo.business.notification.WelcomeToTheGameNotification
|
||||
import eventDemo.configuration.business.configureGameListener
|
||||
import eventDemo.libs.event.projection.ProjectionSnapshotRepositoryInMemory
|
||||
import eventDemo.testKoinApplicationWithConfig
|
||||
import io.kotest.assertions.nondeterministic.until
|
||||
@@ -177,7 +176,6 @@ class GameSimulationTest :
|
||||
val commandHandler by inject<GameCommandHandler>()
|
||||
val eventStore by inject<GameEventStore>()
|
||||
val playerNotificationListener by inject<PlayerNotificationListener>()
|
||||
configureGameListener()
|
||||
playerNotificationListener.startListening(player1, gameId) { channelNotification1.trySendBlocking(it) }
|
||||
playerNotificationListener.startListening(player2, gameId) { channelNotification2.trySendBlocking(it) }
|
||||
|
||||
|
||||
@@ -48,14 +48,13 @@ class GameStateRouteTest :
|
||||
}
|
||||
|
||||
test("/games/{id}/card/last") {
|
||||
testApplicationWithConfig { koin ->
|
||||
val gameId = GameId()
|
||||
val player1 = Player(name = "Nikola")
|
||||
val player2 = Player(name = "Einstein")
|
||||
var lastPlayedCard: Card? = null
|
||||
|
||||
val eventHandler = koin.get<GameEventHandler>()
|
||||
val stateRepo = koin.get<GameStateRepository>()
|
||||
val gameId = GameId()
|
||||
val player1 = Player(name = "Nikola")
|
||||
val player2 = Player(name = "Einstein")
|
||||
var lastPlayedCard: Card? = null
|
||||
testApplicationWithConfig({
|
||||
val eventHandler = get<GameEventHandler>()
|
||||
val stateRepo = get<GameStateRepository>()
|
||||
|
||||
runBlocking {
|
||||
eventHandler.handle(gameId) { NewPlayerEvent(gameId, player1, it) }
|
||||
@@ -89,7 +88,7 @@ class GameStateRouteTest :
|
||||
}
|
||||
delay(100)
|
||||
}
|
||||
|
||||
}) {
|
||||
httpClient()
|
||||
.get("/games/$gameId/card/last") {
|
||||
withAuth(player1)
|
||||
|
||||
Reference in New Issue
Block a user