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) {
|
2020-06-25 14:54:04 +02:00
|
|
|
app, router, _ := NewApiTest()
|
2022-09-28 09:01:17 +02:00
|
|
|
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-06-25 14:54:04 +02:00
|
|
|
|
2020-05-14 18:10:01 +02:00
|
|
|
t.Run("router nil", func(t *testing.T) {
|
2020-06-25 14:54:04 +02:00
|
|
|
app, _, _ := NewApiTest()
|
2022-09-28 09:01:17 +02:00
|
|
|
WebSocket(nil)
|
2020-05-14 18:10:01 +02:00
|
|
|
r := PerformRequest(app, "GET", "/api/v1/ws")
|
|
|
|
assert.Equal(t, http.StatusNotFound, r.Code)
|
|
|
|
})
|
|
|
|
}
|