mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Refactor database models into separate package.
This commit is contained in:
49
model/lower_third_test.go
Normal file
49
model/lower_third_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2014 Team 254. All Rights Reserved.
|
||||
// Author: pat@patfairbank.com (Patrick Fairbank)
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetNonexistentLowerThird(t *testing.T) {
|
||||
db := setupTestDb(t)
|
||||
|
||||
lowerThird, err := db.GetLowerThirdById(1114)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, lowerThird)
|
||||
}
|
||||
|
||||
func TestLowerThirdCrud(t *testing.T) {
|
||||
db := setupTestDb(t)
|
||||
|
||||
lowerThird := LowerThird{0, "Top Text", "Bottom Text", 0}
|
||||
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) {
|
||||
db := setupTestDb(t)
|
||||
|
||||
lowerThird := LowerThird{0, "Top Text", "Bottom Text", 0}
|
||||
db.CreateLowerThird(&lowerThird)
|
||||
db.TruncateLowerThirds()
|
||||
lowerThird2, err := db.GetLowerThirdById(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, lowerThird2)
|
||||
}
|
||||
Reference in New Issue
Block a user