forked from Team254/cheesy-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_sponsor_slides_test.go
52 lines (44 loc) · 1.86 KB
/
setup_sponsor_slides_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
// Copyright 2014 Team 254. All Rights Reserved.
// Author: [email protected] (Patrick Fairbank)
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestSetupSponsorSlides(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.CreateSponsorSlide(&SponsorSlide{0, "Subtitle", "Sponsor Line 1", "Sponsor Line 2", "", 10})
db.CreateSponsorSlide(&SponsorSlide{0, "Subtitle", "", "", "Image.gif", 10})
recorder := getHttpResponse("/setup/sponsor_slides")
assert.Equal(t, 200, recorder.Code)
assert.Contains(t, recorder.Body.String(), "Sponsor Line 1")
assert.Contains(t, recorder.Body.String(), "Image.gif")
recorder = postHttpResponse("/setup/sponsor_slides", "action=delete&id=1")
assert.Equal(t, 302, recorder.Code)
recorder = getHttpResponse("/setup/sponsor_slides")
assert.Equal(t, 200, recorder.Code)
assert.NotContains(t, recorder.Body.String(), "Sponsor Line 1")
assert.Contains(t, recorder.Body.String(), "Image.gif")
recorder = postHttpResponse("/setup/sponsor_slides", "action=save&line2=Sponsor Line 2 revised")
assert.Equal(t, 302, recorder.Code)
recorder = getHttpResponse("/setup/sponsor_slides")
assert.Equal(t, 200, recorder.Code)
assert.Contains(t, recorder.Body.String(), "Sponsor Line 2 revised")
sponsorSlide, _ := db.GetSponsorSlideById(3)
assert.NotNil(t, sponsorSlide)
recorder = postHttpResponse("/setup/sponsor_slides", "action=save&image=Image2.gif&id=2")
assert.Equal(t, 302, recorder.Code)
recorder = getHttpResponse("/setup/sponsor_slides")
assert.Equal(t, 200, recorder.Code)
assert.NotContains(t, recorder.Body.String(), "Image.gif")
assert.Contains(t, recorder.Body.String(), "Image2.gif")
sponsorSlide, _ = db.GetSponsorSlideById(3)
assert.NotNil(t, sponsorSlide)
}