Fix basic tests

This commit is contained in:
Claude Brisson
2024-03-24 08:25:01 +01:00
parent 5ab9256669
commit ca194941fe
4 changed files with 10 additions and 4 deletions

View File

@@ -43,9 +43,11 @@ object PlayerHandler: PairgothApiHandler {
}
val leavingRounds = updated.skip.toSet().minus(player.skip.toSet())
leavingRounds.forEach { round ->
val playing = tournament.games(round).values.flatMap { listOf(it.black, it.white) }
if (playing.contains(id)) {
throw badRequest("player is playing in round #$round")
if (round <= tournament.lastRound()) {
val playing = tournament.games(round).values.flatMap { listOf(it.black, it.white) }
if (playing.contains(id)) {
throw badRequest("player is playing in round #$round")
}
}
}
tournament.players[id] = updated

View File

@@ -25,12 +25,14 @@ interface Store {
fun deleteTournament(tournament: Tournament<*>)
}
private val memoryStore: Store = MemoryStore()
fun getStore(request: HttpServletRequest): Store {
val storeType = WebappManager.getMandatoryProperty("store")
return when (val auth = WebappManager.getMandatoryProperty("auth")) {
"none", "sesame" ->
when (storeType) {
"memory" -> MemoryStore()
"memory" -> memoryStore
"file" -> {
val filePath = WebappManager.properties.getProperty("store.file.path") ?: "."
FileStore(filePath)