Seeding updated

This commit is contained in:
gamer147
2026-05-23 16:25:49 -04:00
parent 5f44ee0c7e
commit 56d3cf0ec8
38 changed files with 52689 additions and 62 deletions

View File

@@ -6,6 +6,7 @@ using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SVSim.Bootstrap.Importers;
using SVSim.Database;
using SVSim.Database.Enums;
using SVSim.Database.Models;
@@ -139,6 +140,21 @@ internal sealed class SVSimTestFactory : WebApplicationFactory<Program>
return viewerId;
}
/// <summary>
/// Runs <see cref="GlobalsImporter"/> against the test SQLite DB using the prod captures
/// copied into the test output dir (see SVSim.UnitTests.csproj Content Include for
/// Data/prod-captures). Idempotent — safe to call multiple times per factory. Tests that
/// depend on prod-shaped global content (spot_cards, avatar abilities, etc.) call this once
/// during setup; the rest of the test runs against whatever the importer populated.
/// </summary>
public async Task SeedGlobalsAsync(string? capturesDir = null)
{
capturesDir ??= Path.Combine(AppContext.BaseDirectory, "Data", "prod-captures");
using var scope = Services.CreateScope();
var ctx = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
await new GlobalsImporter().ImportAllAsync(ctx, capturesDir);
}
/// <summary>Convenience: bake the X-Test-Viewer-Id header into a fresh client.</summary>
public HttpClient CreateAuthenticatedClient(long viewerId)
{