summaryrefslogtreecommitdiff
path: root/sw-server
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-05-05 16:52:27 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-05-12 09:22:25 +0200
commit9aa36cd199c1d6cf0feb959e3ec6ac0539168cd5 (patch)
tree03b40254778add686a1aaf7a263f099e748097fc /sw-server
parentMove score to common model (to enable passing it to client) (diff)
downloadseven-wonders-9aa36cd199c1d6cf0feb959e3ec6ac0539168cd5.tar.gz
seven-wonders-9aa36cd199c1d6cf0feb959e3ec6ac0539168cd5.tar.bz2
seven-wonders-9aa36cd199c1d6cf0feb959e3ec6ac0539168cd5.zip
Upgrade to krossbow 0.20.1 (migrate to flows)
Diffstat (limited to 'sw-server')
-rw-r--r--sw-server/build.gradle.kts2
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt37
2 files changed, 16 insertions, 23 deletions
diff --git a/sw-server/build.gradle.kts b/sw-server/build.gradle.kts
index fcf3ffa4..7d1ee0ae 100644
--- a/sw-server/build.gradle.kts
+++ b/sw-server/build.gradle.kts
@@ -32,7 +32,7 @@ dependencies {
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.hildan.jackstomp:jackstomp:2.0.0")
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin")
- testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-M1")
+ testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5")
}
// packages the frontend app within the jar
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt
index f34234f7..c8a287f7 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt
@@ -1,5 +1,7 @@
package org.luxons.sevenwonders.server
+import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.flow.produceIn
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeout
import kotlinx.coroutines.withTimeoutOrNull
@@ -86,10 +88,11 @@ class SevenWondersTest {
disconnect(ownerSession)
}
+ @OptIn(FlowPreview::class)
@Test
fun createGame_seenByConnectedPlayers() = runAsyncTest {
val otherSession = newPlayer("OtherPlayer")
- val games = otherSession.watchGames().messages
+ val games = otherSession.watchGames().produceIn(this)
var receivedLobbies = withTimeout(500) { games.receive() }
assertNotNull(receivedLobbies)
@@ -109,6 +112,7 @@ class SevenWondersTest {
disconnect(ownerSession, otherSession)
}
+ @OptIn(FlowPreview::class)
@Test
fun startGame_3players() = runAsyncTest {
val session1 = newPlayer("Player1")
@@ -120,27 +124,16 @@ class SevenWondersTest {
val session3 = newPlayer("Player3")
session3.joinGame(lobby.id)
- val gameStart1 = launch { session1.awaitGameStart(lobby.id) }
- val gameStart2 = launch { session2.awaitGameStart(lobby.id) }
- val gameStart3 = launch { session3.awaitGameStart(lobby.id) }
+ listOf(session1, session2, session3).forEach { session ->
+ launch {
+ session.awaitGameStart(lobby.id)
+ val turns = session.watchTurns().produceIn(this)
+ session.sayReady()
+ val turn = turns.receive()
+ assertNotNull(turn)
+ session.disconnect()
+ }
+ }
session1.startGame()
- gameStart1.join()
- gameStart2.join()
- gameStart3.join()
-
- val turns1 = session1.watchTurns().messages
- val turns2 = session2.watchTurns().messages
- val turns3 = session3.watchTurns().messages
- session1.sayReady()
- session2.sayReady()
- session3.sayReady()
- val turn1 = turns1.receive()
- val turn2 = turns2.receive()
- val turn3 = turns3.receive()
- assertNotNull(turn1)
- assertNotNull(turn2)
- assertNotNull(turn3)
-
- disconnect(session1, session2, session3)
}
}
bgstack15