forked from Team254/cheesy-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lower_third_test.go
61 lines (51 loc) · 1.42 KB
/
lower_third_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2014 Team 254. All Rights Reserved.
// Author: [email protected] (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", 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) {
clearDb()
defer clearDb()
db, err := OpenDatabase(testDbPath)
assert.Nil(t, err)
defer db.Close()
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)
}