photoprism/internal/api/websocket_test.go

29 lines
721 B
Go
Raw Normal View History

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