photoprism/internal/api/websocket_test.go

25 lines
508 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("bad request", 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)
})
2020-05-14 18:10:01 +02:00
t.Run("router nil", 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)
})
}