Skip to content

Commit 9acab68

Browse files
committed
AmazonSQS - improve tests
Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
1 parent 65d356f commit 9acab68

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/Host.Plugin.Properties.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Import Project="Common.NuGet.Properties.xml" />
55

66
<PropertyGroup>
7-
<Version>3.0.1</Version>
7+
<Version>3.0.2</Version>
88
</PropertyGroup>
99

1010
</Project>

src/Tests/SlimMessageBus.Host.AmazonSQS.Test/SqsMessageBusIt.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,17 @@ void AdditionalSqsSetup(SqsMessageBusSettings cfg)
4949
var r = await client.ListQueuesAsync(QueueNamePrefix);
5050
foreach (var queueUrl in r.QueueUrls)
5151
{
52-
var tagsResponse = await client.ListQueueTagsAsync(new ListQueueTagsRequest { QueueUrl = queueUrl });
53-
if (!tagsResponse.Tags.TryGetValue(CreatedDateTag, out var createdDateTag) || createdDateTag != today)
52+
try
5453
{
55-
await client.DeleteQueueAsync(queueUrl);
54+
var tagsResponse = await client.ListQueueTagsAsync(new ListQueueTagsRequest { QueueUrl = queueUrl });
55+
if (!tagsResponse.Tags.TryGetValue(CreatedDateTag, out var createdDateTag) || createdDateTag != today)
56+
{
57+
await client.DeleteQueueAsync(queueUrl);
58+
}
59+
}
60+
catch (QueueDoesNotExistException)
61+
{
62+
// ignore, other tests might already have deleted the queue
5663
}
5764
}
5865
await provision();

src/Tests/SlimMessageBus.Host.Test/MessageBusBaseTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,15 +638,17 @@ public async Task When_Start_Given_ConcurrentCalls_Then_ItOnlyStartsConsumersOnc
638638
// trigger lazy bus creation here ahead of the Tasks
639639
var bus = Bus;
640640

641+
await bus.Start();
642+
641643
// act
642644
for (var i = 0; i < 10; i++)
643645
{
644-
await Task.WhenAll(Enumerable.Range(0, 1000).Select(x => bus.Start()).ToList());
646+
await Task.WhenAll(Enumerable.Range(0, 10000).Select(x => bus.Start()).AsParallel());
645647
}
646648

647649
// assert
648-
bus._startedCount.Should().Be(1);
649650
bus._stoppedCount.Should().Be(0);
651+
bus._startedCount.Should().Be(1);
650652
}
651653

652654
[Fact]
@@ -668,8 +670,8 @@ public async Task When_Stop_Given_ConcurrentCalls_Then_ItOnlyStopsConsumersOnce(
668670
}
669671

670672
// assert
671-
bus._startedCount.Should().Be(1);
672673
bus._stoppedCount.Should().Be(1);
674+
bus._startedCount.Should().Be(1);
673675
}
674676

675677
public class ProduceResponseTests

0 commit comments

Comments
 (0)