26 lines
935 B
C#
26 lines
935 B
C#
using Xunit;
|
|
|
|
namespace NeonSprawl.Server.Tests.Game.PositionState;
|
|
|
|
/// <summary>
|
|
/// Collection fixture: ensures Postgres is reachable (starts Docker Compose from repo root when not in CI),
|
|
/// exposes the shared <see cref="PostgresWebApplicationFactory"/>, then disposes the factory and runs
|
|
/// <c>docker compose down</c> only if this harness started Compose.
|
|
/// </summary>
|
|
public sealed class PostgresIntegrationHarness : IAsyncLifetime
|
|
{
|
|
public PostgresWebApplicationFactory Factory { get; } = new();
|
|
|
|
public async Task InitializeAsync()
|
|
{
|
|
await PostgresDockerHelper.EnsurePostgresOrStartDockerAsync(
|
|
Environment.GetEnvironmentVariable("ConnectionStrings__NeonSprawl")).ConfigureAwait(false);
|
|
}
|
|
|
|
public async Task DisposeAsync()
|
|
{
|
|
await Factory.DisposeAsync().ConfigureAwait(false);
|
|
await PostgresDockerHelper.TearDownIfWeStartedAsync().ConfigureAwait(false);
|
|
}
|
|
}
|