mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Copyright 2014 Team 254. All Rights Reserved.
|
|
// Author: pat@patfairbank.com (Patrick Fairbank)
|
|
|
|
package web
|
|
|
|
import (
|
|
"github.com/Team254/cheesy-arena/websocket"
|
|
gorillawebsocket "github.com/gorilla/websocket"
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestPitDisplay(t *testing.T) {
|
|
web := setupTestWeb(t)
|
|
|
|
recorder := web.getHttpResponse("/displays/pit?displayId=1&scrollMsPerRow=700")
|
|
assert.Equal(t, 200, recorder.Code)
|
|
assert.Contains(t, recorder.Body.String(), "Pit Display - Untitled Event - Cheesy Arena")
|
|
}
|
|
|
|
func TestPitDisplayWebsocket(t *testing.T) {
|
|
web := setupTestWeb(t)
|
|
|
|
server, wsUrl := web.startTestServer()
|
|
defer server.Close()
|
|
conn, _, err := gorillawebsocket.DefaultDialer.Dial(wsUrl+"/displays/pit/websocket?displayId=1", nil)
|
|
assert.Nil(t, err)
|
|
defer conn.Close()
|
|
ws := websocket.NewTestWebsocket(conn)
|
|
|
|
// Should get a few status updates right after connection.
|
|
readWebsocketType(t, ws, "displayConfiguration")
|
|
|
|
// Check forced reloading as that is the only purpose the pit websocket serves.
|
|
web.arena.ReloadDisplaysNotifier.Notify()
|
|
readWebsocketType(t, ws, "reload")
|
|
}
|