2019-08-09 23:13:45 -07:00
|
|
|
// Copyright 2019 Team 254. All Rights Reserved.
|
|
|
|
|
// Author: pat@patfairbank.com (Patrick Fairbank)
|
|
|
|
|
|
|
|
|
|
package web
|
|
|
|
|
|
|
|
|
|
import (
|
2021-05-16 11:00:29 -07:00
|
|
|
"github.com/Team254/cheesy-arena-lite/model"
|
2019-08-09 23:13:45 -07:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestSetupAwards(t *testing.T) {
|
|
|
|
|
web := setupTestWeb(t)
|
|
|
|
|
|
|
|
|
|
web.arena.Database.CreateAward(&model.Award{0, model.JudgedAward, "Spirit Award", 0, ""})
|
|
|
|
|
web.arena.Database.CreateAward(&model.Award{0, model.JudgedAward, "Saftey Award", 0, ""})
|
|
|
|
|
|
|
|
|
|
recorder := web.getHttpResponse("/setup/awards")
|
|
|
|
|
assert.Equal(t, 200, recorder.Code)
|
|
|
|
|
assert.Contains(t, recorder.Body.String(), "Spirit Award")
|
|
|
|
|
assert.Contains(t, recorder.Body.String(), "Saftey Award")
|
|
|
|
|
|
|
|
|
|
recorder = web.postHttpResponse("/setup/awards", "action=delete&id=1")
|
|
|
|
|
assert.Equal(t, 303, recorder.Code)
|
|
|
|
|
recorder = web.getHttpResponse("/setup/awards")
|
|
|
|
|
assert.Equal(t, 200, recorder.Code)
|
|
|
|
|
assert.NotContains(t, recorder.Body.String(), "Spirit Award")
|
|
|
|
|
assert.Contains(t, recorder.Body.String(), "Saftey Award")
|
|
|
|
|
|
|
|
|
|
recorder = web.postHttpResponse("/setup/awards", "awardId=2&awardName=Saftey+Award&personName=Englebert")
|
|
|
|
|
assert.Equal(t, 303, recorder.Code)
|
|
|
|
|
recorder = web.getHttpResponse("/setup/awards")
|
|
|
|
|
assert.Equal(t, 200, recorder.Code)
|
|
|
|
|
assert.Contains(t, recorder.Body.String(), "Englebert")
|
|
|
|
|
}
|
2019-09-15 02:09:23 -07:00
|
|
|
|
|
|
|
|
func TestSetupAwardsPublish(t *testing.T) {
|
|
|
|
|
web := setupTestWeb(t)
|
|
|
|
|
|
|
|
|
|
web.arena.TbaClient.BaseUrl = "fakeurl"
|
|
|
|
|
web.arena.EventSettings.TbaPublishingEnabled = true
|
|
|
|
|
|
|
|
|
|
recorder := web.postHttpResponse("/setup/awards/publish", "")
|
|
|
|
|
assert.Equal(t, 500, recorder.Code)
|
|
|
|
|
assert.Contains(t, recorder.Body.String(), "Failed to publish awards")
|
|
|
|
|
}
|