diff --git a/api4/preference_test.go b/api4/preference_test.go index b7e6aa4d13..8c98f0f890 100644 --- a/api4/preference_test.go +++ b/api4/preference_test.go @@ -364,7 +364,6 @@ func TestDeletePreferencesWebsocket(t *testing.T) { require.Nil(t, err) WebSocketClient.Listen() - time.Sleep(300 * time.Millisecond) wsResp := <-WebSocketClient.ResponseChannel require.Equal(t, model.STATUS_OK, wsResp.Status, "should have responded OK to authentication challenge") diff --git a/api4/websocket_test.go b/api4/websocket_test.go index 16dae3c6f3..4716064103 100644 --- a/api4/websocket_test.go +++ b/api4/websocket_test.go @@ -32,22 +32,18 @@ func TestWebSocket(t *testing.T) { WebSocketClient.Listen() - time.Sleep(300 * time.Millisecond) resp := <-WebSocketClient.ResponseChannel require.Equal(t, resp.Status, model.STATUS_OK, "should have responded OK to authentication challenge") WebSocketClient.SendMessage("ping", nil) - time.Sleep(300 * time.Millisecond) resp = <-WebSocketClient.ResponseChannel require.Equal(t, resp.Data["text"].(string), "pong", "wrong response") WebSocketClient.SendMessage("", nil) - time.Sleep(300 * time.Millisecond) resp = <-WebSocketClient.ResponseChannel require.Equal(t, resp.Error.Id, "api.web_socket_router.no_action.app_error", "should have been no action response") WebSocketClient.SendMessage("junk", nil) - time.Sleep(300 * time.Millisecond) resp = <-WebSocketClient.ResponseChannel require.Equal(t, resp.Error.Id, "api.web_socket_router.bad_action.app_error", "should have been bad action response") @@ -55,23 +51,19 @@ func TestWebSocket(t *testing.T) { req.Seq = 0 req.Action = "ping" WebSocketClient.Conn.WriteJSON(req) - time.Sleep(300 * time.Millisecond) resp = <-WebSocketClient.ResponseChannel require.Equal(t, resp.Error.Id, "api.web_socket_router.bad_seq.app_error", "should have been bad action response") WebSocketClient.UserTyping("", "") - time.Sleep(300 * time.Millisecond) resp = <-WebSocketClient.ResponseChannel require.Equal(t, resp.Error.Id, "api.websocket_handler.invalid_param.app_error", "should have been invalid param response") require.Equal(t, resp.Error.DetailedError, "", "detailed error not cleared") WebSocketClient.UserTyping(th.BasicChannel.Id, "") - time.Sleep(300 * time.Millisecond) resp = <-WebSocketClient.ResponseChannel require.Nil(t, resp.Error) WebSocketClient.UserTyping(th.BasicPrivateChannel2.Id, "") - time.Sleep(300 * time.Millisecond) resp = <-WebSocketClient.ResponseChannel require.Equal(t, resp.Error.Id, "api.websocket_handler.invalid_param.app_error", "should have been invalid param response") require.Equal(t, resp.Error.DetailedError, "", "detailed error not cleared") @@ -96,7 +88,6 @@ func TestWebSocketEvent(t *testing.T) { WebSocketClient.Listen() - time.Sleep(300 * time.Millisecond) resp := <-WebSocketClient.ResponseChannel require.Equal(t, resp.Status, model.STATUS_OK, "should have responded OK to authentication challenge") @@ -175,7 +166,6 @@ func TestCreateDirectChannelWithSocket(t *testing.T) { defer WebSocketClient.Close() WebSocketClient.Listen() - time.Sleep(300 * time.Millisecond) resp := <-WebSocketClient.ResponseChannel require.Equal(t, resp.Status, model.STATUS_OK, "should have responded OK to authentication challenge") @@ -272,7 +262,6 @@ func TestWebSocketStatuses(t *testing.T) { defer WebSocketClient.Close() WebSocketClient.Listen() - time.Sleep(300 * time.Millisecond) resp := <-WebSocketClient.ResponseChannel require.Equal(t, resp.Status, model.STATUS_OK, "should have responded OK to authentication challenge") diff --git a/app/web_hub.go b/app/web_hub.go index 935ab2da5d..fd10126db2 100644 --- a/app/web_hub.go +++ b/app/web_hub.go @@ -53,8 +53,8 @@ type Hub struct { func (a *App) NewWebHub() *Hub { return &Hub{ app: a, - register: make(chan *WebConn, 1), - unregister: make(chan *WebConn, 1), + register: make(chan *WebConn), + unregister: make(chan *WebConn), broadcast: make(chan *model.WebSocketEvent, broadcastQueueSize), stop: make(chan struct{}), didStop: make(chan struct{}),