Fix basic tests
This commit is contained in:
@@ -43,11 +43,13 @@ object PlayerHandler: PairgothApiHandler {
|
|||||||
}
|
}
|
||||||
val leavingRounds = updated.skip.toSet().minus(player.skip.toSet())
|
val leavingRounds = updated.skip.toSet().minus(player.skip.toSet())
|
||||||
leavingRounds.forEach { round ->
|
leavingRounds.forEach { round ->
|
||||||
|
if (round <= tournament.lastRound()) {
|
||||||
val playing = tournament.games(round).values.flatMap { listOf(it.black, it.white) }
|
val playing = tournament.games(round).values.flatMap { listOf(it.black, it.white) }
|
||||||
if (playing.contains(id)) {
|
if (playing.contains(id)) {
|
||||||
throw badRequest("player is playing in round #$round")
|
throw badRequest("player is playing in round #$round")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tournament.players[id] = updated
|
tournament.players[id] = updated
|
||||||
tournament.dispatchEvent(PlayerUpdated, request, player.toJson())
|
tournament.dispatchEvent(PlayerUpdated, request, player.toJson())
|
||||||
return Json.Object("success" to true)
|
return Json.Object("success" to true)
|
||||||
|
@@ -25,12 +25,14 @@ interface Store {
|
|||||||
fun deleteTournament(tournament: Tournament<*>)
|
fun deleteTournament(tournament: Tournament<*>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val memoryStore: Store = MemoryStore()
|
||||||
|
|
||||||
fun getStore(request: HttpServletRequest): Store {
|
fun getStore(request: HttpServletRequest): Store {
|
||||||
val storeType = WebappManager.getMandatoryProperty("store")
|
val storeType = WebappManager.getMandatoryProperty("store")
|
||||||
return when (val auth = WebappManager.getMandatoryProperty("auth")) {
|
return when (val auth = WebappManager.getMandatoryProperty("auth")) {
|
||||||
"none", "sesame" ->
|
"none", "sesame" ->
|
||||||
when (storeType) {
|
when (storeType) {
|
||||||
"memory" -> MemoryStore()
|
"memory" -> memoryStore
|
||||||
"file" -> {
|
"file" -> {
|
||||||
val filePath = WebappManager.properties.getProperty("store.file.path") ?: "."
|
val filePath = WebappManager.properties.getProperty("store.file.path") ?: "."
|
||||||
FileStore(filePath)
|
FileStore(filePath)
|
||||||
|
@@ -23,6 +23,7 @@ class BasicTests: TestBase() {
|
|||||||
"shortName" to "mon-tournoi",
|
"shortName" to "mon-tournoi",
|
||||||
"startDate" to "2023-05-10",
|
"startDate" to "2023-05-10",
|
||||||
"endDate" to "2023-05-12",
|
"endDate" to "2023-05-12",
|
||||||
|
"director" to "Nestor Burma",
|
||||||
"country" to "FR",
|
"country" to "FR",
|
||||||
"location" to "Marseille",
|
"location" to "Marseille",
|
||||||
"online" to false,
|
"online" to false,
|
||||||
|
@@ -27,6 +27,7 @@ object TestAPI {
|
|||||||
private fun <T> testRequest(reqMethod: String, uri: String, accept: String = "application/json", payload: T? = null): String {
|
private fun <T> testRequest(reqMethod: String, uri: String, accept: String = "application/json", payload: T? = null): String {
|
||||||
|
|
||||||
WebappManager.properties["auth"] = "none"
|
WebappManager.properties["auth"] = "none"
|
||||||
|
WebappManager.properties["store"] = "memory"
|
||||||
WebappManager.properties["webapp.env"] = "test"
|
WebappManager.properties["webapp.env"] = "test"
|
||||||
|
|
||||||
// mock request
|
// mock request
|
||||||
|
Reference in New Issue
Block a user