photoprism/internal/api/websocket_test.go

25 lines
505 B
Go
Raw Normal View History

2020-05-14 18:10:01 +02:00
package api
import (
"net/http"
"testing"
2020-11-21 18:08:41 +01:00
"github.com/stretchr/testify/assert"
2020-05-14 18:10:01 +02:00
)
func TestWebsocket(t *testing.T) {
t.Run("BadRequest", func(t *testing.T) {
app, router, _ := NewApiTest()
WebSocket(router)
2020-05-14 18:10:01 +02:00
r := PerformRequest(app, "GET", "/api/v1/ws")
assert.Equal(t, http.StatusBadRequest, r.Code)
})
t.Run("NoRouter", func(t *testing.T) {
app, _, _ := NewApiTest()
WebSocket(nil)
2020-05-14 18:10:01 +02:00
r := PerformRequest(app, "GET", "/api/v1/ws")
assert.Equal(t, http.StatusNotFound, r.Code)
})
}