mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Added unit tests for lower thirds.
This commit is contained in:
@@ -77,6 +77,12 @@ func TestAudienceDisplayWebsocket(t *testing.T) {
|
||||
readWebsocketType(t, ws, "realtimeScore")
|
||||
mainArena.scorePostedNotifier.Notify(nil)
|
||||
readWebsocketType(t, ws, "setFinalScore")
|
||||
|
||||
// Test other overlays.
|
||||
mainArena.allianceSelectionNotifier.Notify(nil)
|
||||
readWebsocketType(t, ws, "allianceSelection")
|
||||
mainArena.lowerThirdNotifier.Notify(nil)
|
||||
readWebsocketType(t, ws, "lowerThird")
|
||||
}
|
||||
|
||||
func TestPitDisplay(t *testing.T) {
|
||||
|
||||
61
lower_third_test.go
Normal file
61
lower_third_test.go
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright 2014 Team 254. All Rights Reserved.
|
||||
// Author: pat@patfairbank.com (Patrick Fairbank)
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetNonexistentLowerThird(t *testing.T) {
|
||||
clearDb()
|
||||
defer clearDb()
|
||||
db, err := OpenDatabase(testDbPath)
|
||||
assert.Nil(t, err)
|
||||
defer db.Close()
|
||||
|
||||
lowerThird, err := db.GetLowerThirdById(1114)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, lowerThird)
|
||||
}
|
||||
|
||||
func TestLowerThirdCrud(t *testing.T) {
|
||||
clearDb()
|
||||
defer clearDb()
|
||||
db, err := OpenDatabase(testDbPath)
|
||||
assert.Nil(t, err)
|
||||
defer db.Close()
|
||||
|
||||
lowerThird := LowerThird{0, "Top Text", "Bottom Text"}
|
||||
db.CreateLowerThird(&lowerThird)
|
||||
lowerThird2, err := db.GetLowerThirdById(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, lowerThird, *lowerThird2)
|
||||
|
||||
lowerThird.BottomText = "Blorpy"
|
||||
db.SaveLowerThird(&lowerThird)
|
||||
lowerThird2, err = db.GetLowerThirdById(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, lowerThird.BottomText, lowerThird2.BottomText)
|
||||
|
||||
db.DeleteLowerThird(&lowerThird)
|
||||
lowerThird2, err = db.GetLowerThirdById(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, lowerThird2)
|
||||
}
|
||||
|
||||
func TestTruncateLowerThirds(t *testing.T) {
|
||||
clearDb()
|
||||
defer clearDb()
|
||||
db, err := OpenDatabase(testDbPath)
|
||||
assert.Nil(t, err)
|
||||
defer db.Close()
|
||||
|
||||
lowerThird := LowerThird{0, "Top Text", "Bottom Text"}
|
||||
db.CreateLowerThird(&lowerThird)
|
||||
db.TruncateLowerThirds()
|
||||
lowerThird2, err := db.GetLowerThirdById(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, lowerThird2)
|
||||
}
|
||||
55
setup_lower_thirds_test.go
Normal file
55
setup_lower_thirds_test.go
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright 2014 Team 254. All Rights Reserved.
|
||||
// Author: pat@patfairbank.com (Patrick Fairbank)
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSetupLowerThirds(t *testing.T) {
|
||||
clearDb()
|
||||
defer clearDb()
|
||||
var err error
|
||||
db, err = OpenDatabase(testDbPath)
|
||||
assert.Nil(t, err)
|
||||
defer db.Close()
|
||||
eventSettings, _ = db.GetEventSettings()
|
||||
mainArena.Setup()
|
||||
|
||||
db.CreateLowerThird(&LowerThird{0, "Top Text 1", "Bottom Text 1"})
|
||||
db.CreateLowerThird(&LowerThird{0, "Top Text 2", "Bottom Text 2"})
|
||||
|
||||
recorder := getHttpResponse("/setup/lower_thirds")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "Top Text 1")
|
||||
assert.Contains(t, recorder.Body.String(), "Bottom Text 2")
|
||||
|
||||
recorder = postHttpResponse("/setup/lower_thirds", "action=delete&id=1")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
recorder = getHttpResponse("/setup/lower_thirds")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.NotContains(t, recorder.Body.String(), "Top Text 1")
|
||||
assert.Contains(t, recorder.Body.String(), "Bottom Text 2")
|
||||
|
||||
recorder = postHttpResponse("/setup/lower_thirds", "action=save&topText=Text 3&bottomText=")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
recorder = getHttpResponse("/setup/lower_thirds")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "Text 3")
|
||||
lowerThird, _ := db.GetLowerThirdById(3)
|
||||
assert.NotNil(t, lowerThird)
|
||||
|
||||
recorder = postHttpResponse("/setup/lower_thirds", "action=show&topText=Text 4&bottomText=&id=3")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
recorder = getHttpResponse("/setup/lower_thirds")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "Text 4")
|
||||
lowerThird, _ = db.GetLowerThirdById(3)
|
||||
assert.Equal(t, "Text 4", lowerThird.TopText)
|
||||
assert.Equal(t, "", lowerThird.BottomText)
|
||||
|
||||
recorder = postHttpResponse("/setup/lower_thirds", "action=hide&id=3")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
}
|
||||
Reference in New Issue
Block a user