Skip to content

Commit

Permalink
fix: use test containers for mssql
Browse files Browse the repository at this point in the history
  • Loading branch information
elmaxe committed May 25, 2024
1 parent ce7d50a commit 4f7b1ef
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/dotnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ jobs:
run: dotnet pack --no-build --configuration Release --output ${{ env.NuGetDirectory }}

# Install docker test dependencies
- name: Docker SQL
run: docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Password12!' -e 'MSSQL_PID=Express' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
- name: Docker Azurite
run: docker run -d -p 10000:10000 -p 10001:10001 mcr.microsoft.com/azure-storage/azurite
- name: Docker Redis
run: docker run -d -p 6379:6379 --name redis6379 redis
- name: Docker nats
run: docker run -d -p 4222:4222 nats:latest

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Testcontainers.MsSql" Version="3.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\knightbus\tests\KnightBus.Shared.Tests.Integration\KnightBus.Shared.Tests.Integration.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class SqlSagaStoreTests : SagaStoreTests
{
public override void Setup()
{
SagaStore = new SqlServerSagaStore(DatabaseInitializer.ConnectionString);
SagaStore = new SqlServerSagaStore(SqlServerSetup.ConnectionString);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using NUnit.Framework;
using Testcontainers.MsSql;

namespace KnightBus.SqlServer.Tests.Integration;

[SetUpFixture]
public class SqlServerSetup
{
private const string DatabaseName = "KnightBus";

private static readonly MsSqlContainer MsSql = new MsSqlBuilder()
.WithImage("mcr.microsoft.com/mssql/server:2019-latest")
.WithPortBinding(14333, 1433)
.Build();

public static string ConnectionString;

[OneTimeSetUp]
public async Task OneTimeSetup()
{
await MsSql.StartAsync();
ConnectionString = MsSql.GetConnectionString();
}

[OneTimeTearDown]
public async Task Teardown()
{
await MsSql.DisposeAsync();
}
}

0 comments on commit 4f7b1ef

Please sign in to comment.