Convert EventSettings, Match, and MatchResult models to use Bolt DB.

This commit is contained in:
Patrick Fairbank
2021-05-12 16:40:07 -07:00
parent ea4d56e665
commit 1d523c5f37
28 changed files with 274 additions and 375 deletions

View File

@@ -27,12 +27,13 @@ func TestMatchResultCrud(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, matchResult, matchResult2)
db.SaveMatchResult(matchResult)
matchResult.BlueScore.EndgamePoints = 1234
assert.Nil(t, db.UpdateMatchResult(matchResult))
matchResult2, err = db.GetMatchResultForMatch(254)
assert.Nil(t, err)
assert.Equal(t, matchResult, matchResult2)
db.DeleteMatchResult(matchResult)
assert.Nil(t, db.DeleteMatchResult(matchResult.Id))
matchResult2, err = db.GetMatchResultForMatch(254)
assert.Nil(t, err)
assert.Nil(t, matchResult2)
@@ -43,8 +44,8 @@ func TestTruncateMatchResults(t *testing.T) {
defer db.Close()
matchResult := BuildTestMatchResult(254, 1)
db.CreateMatchResult(matchResult)
db.TruncateMatchResults()
assert.Nil(t, db.CreateMatchResult(matchResult))
assert.Nil(t, db.TruncateMatchResults())
matchResult2, err := db.GetMatchResultForMatch(254)
assert.Nil(t, err)
assert.Nil(t, matchResult2)
@@ -55,11 +56,11 @@ func TestGetMatchResultForMatch(t *testing.T) {
defer db.Close()
matchResult := BuildTestMatchResult(254, 2)
db.CreateMatchResult(matchResult)
assert.Nil(t, db.CreateMatchResult(matchResult))
matchResult2 := BuildTestMatchResult(254, 5)
db.CreateMatchResult(matchResult2)
assert.Nil(t, db.CreateMatchResult(matchResult2))
matchResult3 := BuildTestMatchResult(254, 4)
db.CreateMatchResult(matchResult3)
assert.Nil(t, db.CreateMatchResult(matchResult3))
// Should return the match result with the highest play number (i.e. the most recent).
matchResult4, err := db.GetMatchResultForMatch(254)