diff --git a/server/NeonSprawl.Server.Tests/Game/Skills/SkillProgressionGrantPersistenceIntegrationTests.cs b/server/NeonSprawl.Server.Tests/Game/Skills/SkillProgressionGrantPersistenceIntegrationTests.cs index 5cf5eee..adf0d4a 100644 --- a/server/NeonSprawl.Server.Tests/Game/Skills/SkillProgressionGrantPersistenceIntegrationTests.cs +++ b/server/NeonSprawl.Server.Tests/Game/Skills/SkillProgressionGrantPersistenceIntegrationTests.cs @@ -1,4 +1,7 @@ using System.Net.Http.Json; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using NeonSprawl.Server.Game.PositionState; using NeonSprawl.Server.Game.Skills; using NeonSprawl.Server.Tests.Game.PositionState; using Npgsql; @@ -48,7 +51,7 @@ public sealed class SkillProgressionGrantPersistenceIntegrationTests(PostgresInt Assert.Equal(1, salvage.Level); } - private static async Task ResetProgressionTableAsync() + private async Task ResetProgressionTableAsync() { var cs = Environment.GetEnvironmentVariable("ConnectionStrings__NeonSprawl"); if (string.IsNullOrWhiteSpace(cs)) @@ -56,23 +59,45 @@ public sealed class SkillProgressionGrantPersistenceIntegrationTests(PostgresInt throw new InvalidOperationException("ConnectionStrings__NeonSprawl is not set."); } - var ddlPath = Path.Combine(AppContext.BaseDirectory, "db", "migrations", "V003__player_skill_progression.sql"); - if (!File.Exists(ddlPath)) + _ = Factory.Services; + var options = Factory.Services.GetRequiredService>().Value; + + var positionDdlPath = Path.Combine(AppContext.BaseDirectory, "db", "migrations", "V001__player_position.sql"); + var progressionDdlPath = Path.Combine(AppContext.BaseDirectory, "db", "migrations", "V003__player_skill_progression.sql"); + if (!File.Exists(positionDdlPath)) { - throw new FileNotFoundException($"Test DDL not found at '{ddlPath}'.", ddlPath); + throw new FileNotFoundException($"Test DDL not found at '{positionDdlPath}'.", positionDdlPath); } - var ddl = await File.ReadAllTextAsync(ddlPath); + if (!File.Exists(progressionDdlPath)) + { + throw new FileNotFoundException($"Test DDL not found at '{progressionDdlPath}'.", progressionDdlPath); + } + + var positionDdl = await File.ReadAllTextAsync(positionDdlPath); + var progressionDdl = await File.ReadAllTextAsync(progressionDdlPath); await using var conn = new NpgsqlConnection(cs); await conn.OpenAsync(); - await using (var apply = new NpgsqlCommand(ddl, conn)) + await using (var applyPosition = new NpgsqlCommand(positionDdl, conn)) { - await apply.ExecuteNonQueryAsync(); + await applyPosition.ExecuteNonQueryAsync(); } - await using (var truncate = new NpgsqlCommand("TRUNCATE player_skill_progression;", conn)) + await using (var truncate = new NpgsqlCommand("TRUNCATE player_position CASCADE;", conn)) { await truncate.ExecuteNonQueryAsync(); } + + PostgresPositionBootstrap.SeedDevPlayer(conn, options); + + await using (var applyProgression = new NpgsqlCommand(progressionDdl, conn)) + { + await applyProgression.ExecuteNonQueryAsync(); + } + + await using (var truncateProgression = new NpgsqlCommand("TRUNCATE player_skill_progression;", conn)) + { + await truncateProgression.ExecuteNonQueryAsync(); + } } }