Create test for complete game

create notifications for reply the players
implement notifications on GameEventPlayerNotificationListener
add priority to the eventbus.subscribe()
improve JWT creation
update libs koin + ktor
remove output of GameCommandStream
improve logs
create a function disableShuffleDeck to disable the shuffle of the deck (for tests)
This commit is contained in:
2025-03-08 01:07:45 +01:00
parent 99f0760d3c
commit 51d857513c
55 changed files with 659 additions and 235 deletions

View File

@@ -5,7 +5,10 @@ import io.ktor.websocket.Frame
import io.mockk.mockk
import io.mockk.verify
import kotlinx.coroutines.channels.Channel
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
@Serializable
class CommandTest(
override val id: CommandId,
) : Command
@@ -15,16 +18,12 @@ class CommandStreamChannelTest :
test("send and receive") {
val command = CommandTest(CommandId())
val command2 = CommandTest(CommandId())
val command3 = CommandTest(CommandId())
val channel = Channel<Frame>()
val stream =
CommandStreamChannel<CommandTest>(
incoming = channel,
outgoing = channel,
serializer = { it.id.toString() },
deserializer = { CommandTest(CommandId(it)) },
deserializer = { Json.decodeFromString(it) },
)
val spyCall: () -> Unit = mockk(relaxed = true)
@@ -33,8 +32,7 @@ class CommandStreamChannelTest :
println("In action ${it.id}")
spyCall()
}
stream.send(command, command2)
stream.send(command3)
verify(exactly = 3) { spyCall() }
channel.send(Frame.Text(Json.encodeToString(command)))
verify(exactly = 1) { spyCall() }
}
})