Skip to content

Commit 9feba6f

Browse files
authored
Feature/fix flaky test (#162)
* Fix test not to use hardcoded channel ID (this can fail when tests are executed concurrently on multiple machines) * Remove redundant check (this was needed when channel id was passed as arg)
1 parent 68d491d commit 9feba6f

2 files changed

Lines changed: 5 additions & 26 deletions

File tree

Assets/Plugins/StreamChat/Tests/LowLevelClient/Integration/BaseIntegrationTests.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,6 @@ protected async Task<ChannelState> CreateTempUniqueChannelAsync(string channelTy
7575
{
7676
var channelId = "random-channel-" + Guid.NewGuid();
7777

78-
var channelsResponse = await LowLevelClient.ChannelApi.QueryChannelsAsync(new QueryChannelsRequest()
79-
{
80-
FilterConditions = new Dictionary<string, object>
81-
{
82-
{
83-
"id", new Dictionary<string, object>
84-
{
85-
{ "$in", new[] { channelId } }
86-
}
87-
}
88-
}
89-
});
90-
91-
if (channelsResponse.Channels != null && channelsResponse.Channels.Count > 0)
92-
{
93-
Debug.LogError($"Channel with id {channelId} already exists!");
94-
}
95-
9678
var channelState = await Try(() => LowLevelClient.ChannelApi.GetOrCreateChannelAsync(channelType, channelId,
9779
channelGetOrCreateRequest), state => state != null);
9880

Assets/Plugins/StreamChat/Tests/LowLevelClient/Integration/ChannelApiIntegrationTests.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,14 @@ public IEnumerator When_deleting_non_existing_channel_expect_fail()
338338
{
339339
yield return LowLevelClient.WaitForClientToConnect();
340340

341-
var channelType = "messaging";
342-
var channelId = "new-channel-id-1";
341+
const string channelType = "messaging";
343342

344343
var createChannelTask =
345-
LowLevelClient.ChannelApi.GetOrCreateChannelAsync(channelType, channelId,
346-
new ChannelGetOrCreateRequest());
344+
CreateTempUniqueChannelAsync(channelType, new ChannelGetOrCreateRequest());
347345

348-
yield return createChannelTask.RunAsIEnumerator(response =>
349-
{
350-
Assert.AreEqual(response.Channel.Id, channelId);
351-
});
346+
yield return createChannelTask.RunAsIEnumerator();
347+
348+
var channelId = createChannelTask.Result.Channel.Id;
352349

353350
var deleteChannelTask
354351
= LowLevelClient.ChannelApi.DeleteChannelAsync(channelType, channelId, isHardDelete: false);

0 commit comments

Comments
 (0)