mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Add setting to choose between single- and double-elimination.
This commit is contained in:
@@ -41,10 +41,16 @@ func (web *Web) settingsPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
previousAdminPassword := eventSettings.AdminPassword
|
||||
|
||||
numAlliances, _ := strconv.Atoi(r.PostFormValue("numElimAlliances"))
|
||||
if numAlliances < 2 || numAlliances > 16 {
|
||||
web.renderSettings(w, r, "Number of alliances must be between 2 and 16.")
|
||||
return
|
||||
eventSettings.ElimType = r.PostFormValue("elimType")
|
||||
numAlliances := 0
|
||||
if eventSettings.ElimType == "double" {
|
||||
numAlliances = 8
|
||||
} else {
|
||||
numAlliances, _ = strconv.Atoi(r.PostFormValue("numElimAlliances"))
|
||||
if numAlliances < 2 || numAlliances > 16 {
|
||||
web.renderSettings(w, r, "Number of alliances must be between 2 and 16.")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
eventSettings.NumElimAlliances = numAlliances
|
||||
|
||||
@@ -39,6 +39,15 @@ func TestSetupSettings(t *testing.T) {
|
||||
assert.Contains(t, recorder.Body.String(), "tbasec")
|
||||
}
|
||||
|
||||
func TestSetupSettingsDoubleElimination(t *testing.T) {
|
||||
web := setupTestWeb(t)
|
||||
|
||||
recorder := web.postHttpResponse("/setup/settings", "elimType=double&numElimAlliances=3")
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
assert.Equal(t, "double", web.arena.EventSettings.ElimType)
|
||||
assert.Equal(t, 8, web.arena.EventSettings.NumElimAlliances)
|
||||
}
|
||||
|
||||
func TestSetupSettingsInvalidValues(t *testing.T) {
|
||||
web := setupTestWeb(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user