Skip to content

Commit 4c55f73

Browse files
committed
Update DatabaseFixture.cs
1 parent 9d50200 commit 4c55f73

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CheckDrive.Api/Tests/CheckDrive.Tests.Api/Helpers/DatabaseFixture.cs

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using CheckDrive.Infrastructure.Persistence;
2+
using DotNet.Testcontainers.Builders;
23
using Microsoft.Data.SqlClient;
34
using Microsoft.EntityFrameworkCore;
45
using Testcontainers.MsSql;
@@ -8,7 +9,9 @@ namespace CheckDrive.Tests.Api.Helpers;
89
public class DatabaseFixture : IAsyncLifetime
910
{
1011
private readonly MsSqlContainer _sqlServerContainer = new MsSqlBuilder()
12+
.WithExposedPort(1433)
1113
.WithName("TestDb")
14+
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(1433))
1215
.Build();
1316

1417
private CheckDriveDbContext? _context;
@@ -61,6 +64,10 @@ public async Task InitializeAsync()
6164
catch (Exception ex)
6265
{
6366
Console.WriteLine("There was an error intializing test database, {0}", ex.Message);
67+
68+
var logs = await _sqlServerContainer.GetLogsAsync();
69+
Console.WriteLine("Container Logs: " + logs);
70+
6471
throw;
6572
}
6673
}

0 commit comments

Comments
 (0)