-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate HealthChecks.Rabbitmq tests to Testcontainers
- Loading branch information
Showing
7 changed files
with
82 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
test/HealthChecks.RabbitMQ.Tests/HealthChecks.RabbitMQ.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\HealthChecks.Rabbitmq\HealthChecks.Rabbitmq.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Testcontainers.RabbitMq" /> | ||
</ItemGroup> | ||
</Project> |
35 changes: 35 additions & 0 deletions
35
test/HealthChecks.RabbitMQ.Tests/RabbitMQContainerFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Testcontainers.RabbitMq; | ||
|
||
namespace HealthChecks.RabbitMQ.Tests; | ||
|
||
public sealed class RabbitMQContainerFixture : IAsyncLifetime | ||
{ | ||
public const string Registry = "docker.io"; | ||
|
||
public const string Image = "library/rabbitmq"; | ||
|
||
public const string Tag = "4.0"; | ||
|
||
public RabbitMqContainer? Container { get; private set; } | ||
|
||
public string GetConnectionString() => Container?.GetConnectionString() ?? | ||
throw new InvalidOperationException("The test container was not initialized."); | ||
|
||
public async Task InitializeAsync() => Container = await CreateContainerAsync(); | ||
|
||
public async Task DisposeAsync() | ||
{ | ||
if (Container is not null) | ||
await Container.DisposeAsync(); | ||
} | ||
|
||
public static async Task<RabbitMqContainer> CreateContainerAsync() | ||
{ | ||
var container = new RabbitMqBuilder() | ||
.WithImage($"{Registry}/{Image}:{Tag}") | ||
.Build(); | ||
await container.StartAsync(); | ||
|
||
return container; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters