2014-05-24 17:58:57 -07:00
|
|
|
// Copyright 2014 Team 254. All Rights Reserved.
|
|
|
|
|
// Author: pat@patfairbank.com (Patrick Fairbank)
|
|
|
|
|
|
2017-08-23 22:41:56 -07:00
|
|
|
package model
|
2014-05-24 17:58:57 -07:00
|
|
|
|
|
|
|
|
import (
|
2014-05-25 23:03:50 -07:00
|
|
|
"github.com/stretchr/testify/assert"
|
2014-05-24 17:58:57 -07:00
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestEventSettingsReadWrite(t *testing.T) {
|
2017-08-23 22:41:56 -07:00
|
|
|
db := setupTestDb(t)
|
2021-05-09 21:12:23 -07:00
|
|
|
defer db.Close()
|
2014-05-25 17:21:42 -07:00
|
|
|
|
2014-05-24 17:58:57 -07:00
|
|
|
eventSettings, err := db.GetEventSettings()
|
2014-05-25 23:03:50 -07:00
|
|
|
assert.Nil(t, err)
|
2021-05-12 16:40:07 -07:00
|
|
|
assert.Equal(t, EventSettings{Id: 1, Name: "Untitled Event", NumElimAlliances: 8, SelectionRound2Order: "L",
|
2018-09-22 11:15:29 -07:00
|
|
|
SelectionRound3Order: "", TBADownloadEnabled: true, ApTeamChannel: 157, ApAdminChannel: 0,
|
2020-03-15 22:24:23 -07:00
|
|
|
ApAdminWpaKey: "1234Five", WarmupDurationSec: 0, AutoDurationSec: 15, PauseDurationSec: 2,
|
2020-04-14 19:38:14 -05:00
|
|
|
TeleopDurationSec: 135, WarningRemainingDurationSec: 30}, *eventSettings)
|
2014-05-24 17:58:57 -07:00
|
|
|
|
|
|
|
|
eventSettings.Name = "Chezy Champs"
|
2014-06-06 21:26:55 -07:00
|
|
|
eventSettings.NumElimAlliances = 6
|
|
|
|
|
eventSettings.SelectionRound2Order = "F"
|
|
|
|
|
eventSettings.SelectionRound3Order = "L"
|
2021-05-12 16:40:07 -07:00
|
|
|
err = db.UpdateEventSettings(eventSettings)
|
2014-05-25 23:03:50 -07:00
|
|
|
assert.Nil(t, err)
|
2014-05-24 17:58:57 -07:00
|
|
|
eventSettings2, err := db.GetEventSettings()
|
2014-05-25 23:03:50 -07:00
|
|
|
assert.Nil(t, err)
|
2017-08-05 20:48:17 -07:00
|
|
|
assert.Equal(t, eventSettings, eventSettings2)
|
2014-05-24 17:58:57 -07:00
|
|
|
}
|