Fix SimpleMM test

This commit is contained in:
Claude Brisson
2024-03-25 05:34:14 +01:00
parent 8cd0b7d15e
commit 7da3670cb8
3 changed files with 25 additions and 8 deletions

View File

@@ -2,10 +2,19 @@ package org.jeudego.pairgoth.store
import org.jeudego.pairgoth.model.ID
import org.jeudego.pairgoth.model.Tournament
import java.util.concurrent.atomic.AtomicInteger
class MemoryStore: Store {
object MemoryStore: Store {
private val tournaments = mutableMapOf<ID, Tournament<*>>()
// for tests
fun reset() {
tournaments.clear()
_nextTournamentId.set(0)
_nextPlayerId.set(0)
_nextGameId.set(0)
}
override fun getTournaments(): Map<ID, Map<String, String>> = tournaments.mapValues {
mapOf("name" to it.value.shortName)
}

View File

@@ -28,14 +28,12 @@ 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)