refactor(bootstrap): finalize seed migration; remove GlobalsImporter and prod-captures plumbing
Final cleanup of the bootstrap-seed refactor (Task 10 of 10): - Delete the GlobalsImporter no-op stub and its two remaining call sites (Program.cs and SVSimTestFactory.cs). All work has moved to per-domain importers since Task 9. - Drop the --captures CLI flag and CapturesDir / shippedCaptures plumbing from Program.cs (BootstrapOptions, ParseArgs, PrintUsage). Bootstrap input is now cards.json + reference CSVs + per-table seed JSON; no more prod-captures directory. - Shrink ImporterBase from 141 to 23 lines: LoadCapture, Serialize, Upsert<T,TKey>, GetInt/GetString/GetBool/GetLong/GetULong all had zero callers after the seed migration. Only ParseWireDateTime survives (still used by PaymentItemImporter and MyPageGlobalsImporter for prod-shaped timestamp strings). - Remove the prod-captures Content Include glob from SVSim.Bootstrap.csproj and both prod-captures globs (production + test-fixture overlay) from SVSim.UnitTests.csproj. Test fixtures now overlay production seeds at Data/seeds/ via the Task 7 layout exclusively. Build clean; 391/391 unit tests passing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -176,21 +176,19 @@ internal sealed class SVSimTestFactory : WebApplicationFactory<Program>
|
||||
}
|
||||
|
||||
/// <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.
|
||||
/// Runs the per-domain seed importers against the test SQLite DB using the seed JSON
|
||||
/// copied into the test output dir (see SVSim.UnitTests.csproj Content Includes for
|
||||
/// Data/seeds and Data/test-fixtures/seeds). Idempotent — safe to call multiple times.
|
||||
/// 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 importers
|
||||
/// populated. Mirrors the wiring in <see cref="SVSim.Bootstrap.Program"/>.
|
||||
/// </summary>
|
||||
public async Task SeedGlobalsAsync(string? capturesDir = null)
|
||||
public async Task SeedGlobalsAsync()
|
||||
{
|
||||
capturesDir ??= Path.Combine(AppContext.BaseDirectory, "Data", "prod-captures");
|
||||
string seedDir = Path.Combine(AppContext.BaseDirectory, "Data", "seeds");
|
||||
using var scope = Services.CreateScope();
|
||||
var ctx = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||
await new GlobalsImporter().ImportAllAsync(ctx, capturesDir);
|
||||
|
||||
// Load-index seed pipeline (Stage 9C). Mirrors the wiring in SVSim.Bootstrap.Program.cs:
|
||||
// RotationConfigImporter must precede RotationFlagUpdater; CardListsImporter is
|
||||
// ordered after the GameConfig importers for tidiness (no FK dependency).
|
||||
await new RotationConfigImporter().ImportAsync(ctx, seedDir);
|
||||
@@ -203,7 +201,6 @@ internal sealed class SVSimTestFactory : WebApplicationFactory<Program>
|
||||
await new CardListsImporter().ImportAsync(ctx, seedDir);
|
||||
await new RotationFlagUpdater().UpdateAsync(ctx);
|
||||
|
||||
// Per-importer seed pipeline for the rest of the load-index split.
|
||||
await new PracticeOpponentImporter().ImportAsync(ctx, seedDir);
|
||||
await new PaymentItemImporter().ImportAsync(ctx, seedDir);
|
||||
var puzzleImporter = new PuzzleImporter();
|
||||
|
||||
@@ -36,14 +36,8 @@
|
||||
<Content Include="..\SVSim.Bootstrap\Data\*.csv" Link="Data\%(Filename)%(Extension)">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<!-- Tests that call SVSimTestFactory.SeedGlobalsAsync() need the prod captures available in
|
||||
the test output dir. Mirror them from SVSim.Bootstrap so the same files drive both
|
||||
production bootstrap and test seeding. -->
|
||||
<Content Include="..\SVSim.Bootstrap\Data\prod-captures\*.json" Link="Data\prod-captures\%(Filename)%(Extension)">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<!-- Seed JSON files for the per-importer pipeline (replaces prod-captures during migration).
|
||||
Both globs coexist while individual endpoints are still being converted. -->
|
||||
<!-- Production per-table seed JSON for the per-domain importer pipeline. Same files
|
||||
consumed by SVSim.Bootstrap; mirrored here so SeedGlobalsAsync sees them. -->
|
||||
<Content Include="..\SVSim.Bootstrap\Data\seeds\**\*.json" Link="Data\seeds\%(RecursiveDir)%(Filename)%(Extension)">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -54,14 +48,6 @@
|
||||
<Content Include="..\SVSim.Bootstrap\Data\test-fixtures\seeds\*.json" Link="Data\seeds\%(Filename)%(Extension)">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<!-- Test-only fixtures live outside prod-captures so the production bootstrap glob doesn't
|
||||
pick them up (a fixture-named file would win the importer's reverse-alphabetical sort
|
||||
against a dated capture). Linked into the same test output dir so SeedGlobalsAsync sees
|
||||
them; per-feature tests rely on the fixture, the prod-capture smoke test routes around it
|
||||
via a temp dir. -->
|
||||
<Content Include="..\SVSim.Bootstrap\Data\test-fixtures\*.json" Link="Data\prod-captures\%(Filename)%(Extension)">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<!-- StoryImporter integration test fixtures — copied to Story\Fixtures\ in test output. -->
|
||||
<Content Include="Story\Fixtures\*.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
||||
Reference in New Issue
Block a user