mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Convert AllianceTeam, Award, and LowerThird models to use Bolt DB.
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
func TestGetNonexistentLowerThird(t *testing.T) {
|
||||
db := setupTestDb(t)
|
||||
defer db.Close()
|
||||
|
||||
lowerThird, err := db.GetLowerThirdById(1114)
|
||||
assert.Nil(t, err)
|
||||
@@ -18,20 +19,29 @@ func TestGetNonexistentLowerThird(t *testing.T) {
|
||||
|
||||
func TestLowerThirdCrud(t *testing.T) {
|
||||
db := setupTestDb(t)
|
||||
defer db.Close()
|
||||
|
||||
lowerThird := LowerThird{0, "Top Text", "Bottom Text", 0, 0}
|
||||
db.CreateLowerThird(&lowerThird)
|
||||
lowerThirds, err := db.GetAllLowerThirds()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, len(lowerThirds))
|
||||
|
||||
lowerThird := LowerThird{0, "Top Text", "Bottom Text", 1, 0}
|
||||
assert.Nil(t, db.CreateLowerThird(&lowerThird))
|
||||
lowerThird2, err := db.GetLowerThirdById(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, lowerThird, *lowerThird2)
|
||||
|
||||
lowerThird.BottomText = "Blorpy"
|
||||
db.SaveLowerThird(&lowerThird)
|
||||
assert.Nil(t, db.UpdateLowerThird(&lowerThird))
|
||||
lowerThird2, err = db.GetLowerThirdById(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, lowerThird.BottomText, lowerThird2.BottomText)
|
||||
|
||||
db.DeleteLowerThird(&lowerThird)
|
||||
lowerThirds, err = db.GetAllLowerThirds()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 1, len(lowerThirds))
|
||||
|
||||
assert.Nil(t, db.DeleteLowerThird(lowerThird.Id))
|
||||
lowerThird2, err = db.GetLowerThirdById(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, lowerThird2)
|
||||
@@ -39,10 +49,11 @@ func TestLowerThirdCrud(t *testing.T) {
|
||||
|
||||
func TestTruncateLowerThirds(t *testing.T) {
|
||||
db := setupTestDb(t)
|
||||
defer db.Close()
|
||||
|
||||
lowerThird := LowerThird{0, "Top Text", "Bottom Text", 0, 0}
|
||||
db.CreateLowerThird(&lowerThird)
|
||||
db.TruncateLowerThirds()
|
||||
assert.Nil(t, db.CreateLowerThird(&lowerThird))
|
||||
assert.Nil(t, db.TruncateLowerThirds())
|
||||
lowerThird2, err := db.GetLowerThirdById(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, lowerThird2)
|
||||
@@ -50,18 +61,25 @@ func TestTruncateLowerThirds(t *testing.T) {
|
||||
|
||||
func TestGetLowerThirdsByAwardId(t *testing.T) {
|
||||
db := setupTestDb(t)
|
||||
lowerThird1 := LowerThird{0, "Top Text", "Bottom Text", 0, 0}
|
||||
db.CreateLowerThird(&lowerThird1)
|
||||
lowerThird2 := LowerThird{0, "Award 1", "", 1, 5}
|
||||
db.CreateLowerThird(&lowerThird2)
|
||||
lowerThird3 := LowerThird{0, "Award 2", "", 2, 2}
|
||||
db.CreateLowerThird(&lowerThird3)
|
||||
lowerThird4 := LowerThird{0, "Award 1", "Award 1 Winner", 3, 5}
|
||||
db.CreateLowerThird(&lowerThird4)
|
||||
nextDisplayOrder := db.GetNextLowerThirdDisplayOrder()
|
||||
assert.Equal(t, 4, nextDisplayOrder)
|
||||
defer db.Close()
|
||||
|
||||
lowerThirds, err := db.GetLowerThirdsByAwardId(5)
|
||||
nextDisplayOrder := db.GetNextLowerThirdDisplayOrder()
|
||||
assert.Equal(t, 1, nextDisplayOrder)
|
||||
lowerThird1 := LowerThird{0, "Top Text", "Bottom Text", 1, 0}
|
||||
assert.Nil(t, db.CreateLowerThird(&lowerThird1))
|
||||
lowerThird2 := LowerThird{0, "Award 1", "", 2, 5}
|
||||
assert.Nil(t, db.CreateLowerThird(&lowerThird2))
|
||||
lowerThird3 := LowerThird{0, "Award 2", "", 3, 2}
|
||||
assert.Nil(t, db.CreateLowerThird(&lowerThird3))
|
||||
lowerThird4 := LowerThird{0, "Award 1", "Award 1 Winner", 4, 5}
|
||||
assert.Nil(t, db.CreateLowerThird(&lowerThird4))
|
||||
lowerThirds, err := db.GetAllLowerThirds()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 4, len(lowerThirds))
|
||||
nextDisplayOrder = db.GetNextLowerThirdDisplayOrder()
|
||||
assert.Equal(t, 5, nextDisplayOrder)
|
||||
|
||||
lowerThirds, err = db.GetLowerThirdsByAwardId(5)
|
||||
assert.Nil(t, err)
|
||||
if assert.Equal(t, 2, len(lowerThirds)) {
|
||||
assert.Equal(t, lowerThird2, lowerThirds[0])
|
||||
@@ -72,4 +90,7 @@ func TestGetLowerThirdsByAwardId(t *testing.T) {
|
||||
if assert.Equal(t, 1, len(lowerThirds)) {
|
||||
assert.Equal(t, lowerThird3, lowerThirds[0])
|
||||
}
|
||||
lowerThirds, err = db.GetLowerThirdsByAwardId(39)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, len(lowerThirds))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user