Skip to content

Commit b974f93

Browse files
committed
build: bump testcontainers
1 parent 6486b91 commit b974f93

2 files changed

Lines changed: 8 additions & 19 deletions

File tree

QueryKit.IntegrationTests/QueryKit.IntegrationTests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.5" />
1818
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.5" />
1919
<PackageReference Include="Moq" Version="4.18.4" />
20-
<PackageReference Include="Testcontainers" Version="2.4.0" />
20+
<PackageReference Include="Testcontainers" Version="3.3.0" />
21+
<PackageReference Include="Testcontainers.PostgreSql" Version="3.3.0" />
2122
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
2223
<PackageReference Include="xunit" Version="2.4.2" />
2324
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

QueryKit.IntegrationTests/TestFixture.cs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace QueryKit.IntegrationTests;
1111
using Microsoft.Extensions.DependencyInjection;
1212
using Microsoft.Extensions.DependencyInjection.Extensions;
1313
using Moq;
14+
using Testcontainers.PostgreSql;
1415
using WebApiTestProject;
1516
using WebApiTestProject.Database;
1617
using Xunit;
@@ -21,7 +22,7 @@ public class TestFixtureCollection : ICollectionFixture<TestFixture> {}
2122
public class TestFixture : IAsyncLifetime
2223
{
2324
public static IServiceScopeFactory BaseScopeFactory;
24-
private readonly TestcontainerDatabase _dbContainer = DbSetup();
25+
private PostgreSqlContainer _dbContainer;
2526

2627
public async Task InitializeAsync()
2728
{
@@ -30,9 +31,10 @@ public async Task InitializeAsync()
3031
EnvironmentName = Consts.Testing.IntegrationTestingEnvName
3132
});
3233

34+
_dbContainer = new PostgreSqlBuilder().Build();
3335
await _dbContainer.StartAsync();
34-
builder.Configuration.GetSection(ConnectionStringOptions.SectionName)[ConnectionStringOptions.RecipeManagementKey] = _dbContainer.ConnectionString;
35-
await RunMigration(_dbContainer.ConnectionString);
36+
builder.Configuration.GetSection(ConnectionStringOptions.SectionName)[ConnectionStringOptions.RecipeManagementKey] = _dbContainer.GetConnectionString();
37+
await RunMigration(_dbContainer.GetConnectionString());
3638

3739
builder.ConfigureServices();
3840
var services = builder.Services;
@@ -53,21 +55,7 @@ private static async Task RunMigration(string connectionString)
5355
var context = new TestingDbContext(options);
5456
await context?.Database?.MigrateAsync();
5557
}
56-
57-
private static TestcontainerDatabase DbSetup()
58-
{
59-
return new TestcontainersBuilder<PostgreSqlTestcontainer>()
60-
.WithDatabase(new PostgreSqlTestcontainerConfiguration
61-
{
62-
Database = "db",
63-
Username = "postgres",
64-
Password = "postgres"
65-
})
66-
.WithName($"IntegrationTesting_QueryKit_{Guid.NewGuid()}")
67-
.WithImage("postgres:latest")
68-
.Build();
69-
}
70-
58+
7159
public async Task DisposeAsync()
7260
{
7361
await _dbContainer.DisposeAsync();

0 commit comments

Comments
 (0)