2017-08-27 16:27:02 -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 model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
2021-05-16 11:00:29 -07:00
|
|
|
"github.com/Team254/cheesy-arena-lite/game"
|
2017-08-27 16:27:02 -07:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
2017-08-28 20:14:32 -07:00
|
|
|
func SetupTestDb(t *testing.T, uniqueName string) *Database {
|
|
|
|
|
BaseDir = ".."
|
2017-08-31 23:26:22 -07:00
|
|
|
dbPath := filepath.Join(BaseDir, fmt.Sprintf("%s_test.db", uniqueName))
|
|
|
|
|
os.Remove(dbPath)
|
2017-08-28 20:14:32 -07:00
|
|
|
database, err := OpenDatabase(dbPath)
|
2017-08-27 16:27:02 -07:00
|
|
|
assert.Nil(t, err)
|
|
|
|
|
return database
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-12 17:49:05 -07:00
|
|
|
func BuildTestMatchResult(matchId int, playNumber int) *MatchResult {
|
2017-08-27 16:27:02 -07:00
|
|
|
matchResult := &MatchResult{MatchId: matchId, PlayNumber: playNumber, MatchType: "qualification"}
|
|
|
|
|
matchResult.RedScore = game.TestScore1()
|
|
|
|
|
matchResult.BlueScore = game.TestScore2()
|
|
|
|
|
return matchResult
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BuildTestAlliances(database *Database) {
|
2022-07-31 12:08:43 -07:00
|
|
|
database.CreateAlliance(&Alliance{Id: 2, TeamIds: []int{1718, 2451, 1619}, Lineup: [3]int{2451, 1718, 1619}})
|
|
|
|
|
database.CreateAlliance(&Alliance{Id: 1, TeamIds: []int{254, 469, 2848, 74, 3175}, Lineup: [3]int{469, 254, 2848}})
|
2017-08-27 16:27:02 -07:00
|
|
|
}
|