Seeding updated
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user