From ed2cd0e55219501208cf28d53e5d920a01b9cf1c Mon Sep 17 00:00:00 2001 From: Ibrahim Serdar Acikgoz Date: Tue, 29 Sep 2020 13:54:38 +0300 Subject: [PATCH] [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 --- api4/channel_test.go | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/api4/channel_test.go b/api4/channel_test.go index f46c024e1a..bc419379ec 100644 --- a/api4/channel_test.go +++ b/api4/channel_test.go @@ -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) {