-
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.
Merge branch 'master' into alirexaa/postgres-testscontainers
- Loading branch information
Showing
6 changed files
with
53 additions
and
84 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
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
4 changes: 4 additions & 0 deletions
4
test/HealthChecks.SqlServer.Tests/HealthChecks.SqlServer.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
35 changes: 35 additions & 0 deletions
35
test/HealthChecks.SqlServer.Tests/SqlServerContainerFixture.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.MsSql; | ||
|
||
namespace HealthChecks.SqlServer.Tests; | ||
|
||
public sealed class SqlServerContainerFixture : IAsyncLifetime | ||
{ | ||
public const string Registry = "mcr.microsoft.com"; | ||
|
||
public const string Image = "mssql/server"; | ||
|
||
public const string Tag = "2022-latest"; | ||
|
||
public MsSqlContainer? 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<MsSqlContainer> CreateContainerAsync() | ||
{ | ||
var container = new MsSqlBuilder() | ||
.WithImage($"{Registry}/{Image}:{Tag}") | ||
.Build(); | ||
await container.StartAsync(); | ||
|
||
return container; | ||
} | ||
} |