Skip to content

Commit

Permalink
test: add postgresql testcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
EnisMulic committed Nov 6, 2023
1 parent b864660 commit 8e276ea
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/Application.IntegrationTests/TestContainersDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,37 @@

using Respawn;

#if UseMsSql
using Testcontainers.MsSql;
#else
using Testcontainers.PostgreSql;

Check warning on line 13 in tests/Application.IntegrationTests/TestContainersDatabase.cs

View workflow job for this annotation

GitHub Actions / build

Using directive is unnecessary.

Check warning on line 13 in tests/Application.IntegrationTests/TestContainersDatabase.cs

View workflow job for this annotation

GitHub Actions / build

Using directive is unnecessary.
#endif

namespace Application.IntegrationTests;

public class TestContainersDatabase : ITestDatabase
{
#if UseMsSql
private readonly MsSqlContainer _container;
#else
private readonly PostgreSqlContainer _container;

Check failure on line 23 in tests/Application.IntegrationTests/TestContainersDatabase.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'PostgreSqlContainer' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 23 in tests/Application.IntegrationTests/TestContainersDatabase.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'PostgreSqlContainer' could not be found (are you missing a using directive or an assembly reference?)
#endif

private DbConnection _connection = null!;
private string _connectionString = null!;
private Respawner _respawner = null!;

public TestContainersDatabase()
{
#if UseMsSql
_container = new MsSqlBuilder()
.WithAutoRemove(true)
.Build();
#else
_container = new PostgreSqlBuilder()

Check failure on line 37 in tests/Application.IntegrationTests/TestContainersDatabase.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'PostgreSqlBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 37 in tests/Application.IntegrationTests/TestContainersDatabase.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'PostgreSqlBuilder' could not be found (are you missing a using directive or an assembly reference?)
.WithAutoRemove(true)
.Build();
#endif
}

public async Task InitialiseAsync()
Expand Down

0 comments on commit 8e276ea

Please sign in to comment.