2017-08-28 20:14:32 -07:00
|
|
|
// Copyright 2017 Team 254. All Rights Reserved.
|
|
|
|
|
// Author: pat@patfairbank.com (Patrick Fairbank)
|
|
|
|
|
//
|
|
|
|
|
// Helper methods for use in tests in this package and others.
|
|
|
|
|
|
|
|
|
|
package field
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
2021-05-16 11:00:29 -07:00
|
|
|
"github.com/Team254/cheesy-arena-lite/game"
|
|
|
|
|
"github.com/Team254/cheesy-arena-lite/model"
|
2017-08-28 20:14:32 -07:00
|
|
|
"github.com/stretchr/testify/assert"
|
2018-09-09 22:42:38 -07:00
|
|
|
"math/rand"
|
2017-08-28 20:14:32 -07:00
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func SetupTestArena(t *testing.T, uniqueName string) *Arena {
|
2018-09-09 22:42:38 -07:00
|
|
|
rand.Seed(0)
|
2017-08-31 23:26:22 -07:00
|
|
|
model.BaseDir = ".."
|
|
|
|
|
dbPath := filepath.Join(model.BaseDir, fmt.Sprintf("%s_test.db", uniqueName))
|
|
|
|
|
os.Remove(dbPath)
|
2017-08-28 20:14:32 -07:00
|
|
|
arena, err := NewArena(dbPath)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
return arena
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func setupTestArena(t *testing.T) *Arena {
|
2019-04-12 17:32:40 -07:00
|
|
|
game.MatchTiming.WarmupDurationSec = 3
|
|
|
|
|
game.MatchTiming.PauseDurationSec = 2
|
2017-08-28 20:14:32 -07:00
|
|
|
return SetupTestArena(t, "field")
|
|
|
|
|
}
|