forked from Team254/cheesy-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sponsor_slide_test.go
61 lines (51 loc) · 1.5 KB
/
sponsor_slide_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 TestGetNonexistentSponsorSlide(t *testing.T) {
clearDb()
defer clearDb()
db, err := OpenDatabase(testDbPath)
assert.Nil(t, err)
defer db.Close()
sponsorSlide, err := db.GetSponsorSlideById(1114)
assert.Nil(t, err)
assert.Nil(t, sponsorSlide)
}
func TestSponsorSlideCrud(t *testing.T) {
clearDb()
defer clearDb()
db, err := OpenDatabase(testDbPath)
assert.Nil(t, err)
defer db.Close()
sponsorSlide := SponsorSlide{0, "Subtitle", "Line 1", "Line 2", "", 10}
db.CreateSponsorSlide(&sponsorSlide)
sponsorSlide2, err := db.GetSponsorSlideById(1)
assert.Nil(t, err)
assert.Equal(t, sponsorSlide, *sponsorSlide2)
sponsorSlide.Line1 = "Blorpy"
db.SaveSponsorSlide(&sponsorSlide)
sponsorSlide2, err = db.GetSponsorSlideById(1)
assert.Nil(t, err)
assert.Equal(t, sponsorSlide.Line1, sponsorSlide2.Line1)
db.DeleteSponsorSlide(&sponsorSlide)
sponsorSlide2, err = db.GetSponsorSlideById(1)
assert.Nil(t, err)
assert.Nil(t, sponsorSlide2)
}
func TestTruncateSponsorSlides(t *testing.T) {
clearDb()
defer clearDb()
db, err := OpenDatabase(testDbPath)
assert.Nil(t, err)
defer db.Close()
sponsorSlide := SponsorSlide{0, "Subtitle", "Line 1", "Line 2", "", 10}
db.CreateSponsorSlide(&sponsorSlide)
db.TruncateSponsorSlides()
sponsorSlide2, err := db.GetSponsorSlideById(1)
assert.Nil(t, err)
assert.Nil(t, sponsorSlide2)
}