[MM-28028] api4/channel_test: increase timeout fir the case if event is not recieved in time (#15344)

* api4/channel_test: skip if event is not recieved in time

* api4/channel: TestConvertChannelToPrivate increase timeout

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Ibrahim Serdar Acikgoz
2020-09-29 13:54:38 +03:00
committed by GitHub
parent c8c7fe0f4f
commit ed2cd0e552

View File

@@ -1714,27 +1714,19 @@ func TestConvertChannelToPrivate(t *testing.T) {
CheckOKStatus(t, resp)
require.Equal(t, model.CHANNEL_PRIVATE, rchannel.Type, "channel should be converted from public to private")
stop := make(chan bool)
eventHit := false
timeout := time.After(10 * time.Second)
go func() {
for {
select {
case resp := <-WebSocketClient.EventChannel:
if resp.EventType() == model.WEBSOCKET_EVENT_CHANNEL_CONVERTED && resp.GetData()["channel_id"].(string) == publicChannel2.Id {
eventHit = true
}
case <-stop:
for {
select {
case resp := <-WebSocketClient.EventChannel:
if resp.EventType() == model.WEBSOCKET_EVENT_CHANNEL_CONVERTED && resp.GetData()["channel_id"].(string) == publicChannel2.Id {
return
}
case <-timeout:
require.Fail(t, "timed out waiting for channel_converted event")
return
}
}()
time.Sleep(400 * time.Millisecond)
stop <- true
require.True(t, eventHit, "did not receive channel_converted event")
}
}
func TestUpdateChannelPrivacy(t *testing.T) {