2026-06-09 06:41:28 +03:30
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
|
|
|
|
|
|
|
|
namespace TeamUp.IntegrationTests;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Drives the real <see cref="Program"/> web host against the test container, in Development so
|
|
|
|
|
/// migrations apply on startup and the OpenAPI document is mapped.
|
|
|
|
|
/// </summary>
|
2026-06-09 18:34:53 +03:30
|
|
|
public sealed class TeamUpWebFactory(
|
|
|
|
|
string connectionString,
|
|
|
|
|
IReadOnlyDictionary<string, string?>? settings = null) : WebApplicationFactory<Program>
|
2026-06-09 06:41:28 +03:30
|
|
|
{
|
2026-06-13 11:09:02 +03:30
|
|
|
/// <summary>Operator key the test host accepts for builtin management (/index, /sync).</summary>
|
|
|
|
|
public const string PlatformAdminKey = "test-admin-key";
|
|
|
|
|
|
|
|
|
|
|
2026-06-09 06:41:28 +03:30
|
|
|
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
builder.UseEnvironment("Development");
|
|
|
|
|
builder.UseSetting("ConnectionStrings:Postgres", connectionString);
|
|
|
|
|
builder.UseSetting("Database:ApplyMigrationsOnStartup", "true");
|
|
|
|
|
builder.UseSetting("OpenTelemetry:OtlpEndpoint", string.Empty);
|
2026-06-13 11:09:02 +03:30
|
|
|
builder.UseSetting("Skills:AdminKey", PlatformAdminKey);
|
2026-06-09 18:34:53 +03:30
|
|
|
|
|
|
|
|
if (settings is not null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var (key, value) in settings)
|
|
|
|
|
{
|
|
|
|
|
builder.UseSetting(key, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-06-09 06:41:28 +03:30
|
|
|
}
|
|
|
|
|
}
|