chore(backend): add explicit test data seed command
All checks were successful
deploy-socialize / image (push) Successful in 53s
deploy-socialize / deploy (push) Successful in 21s

This commit is contained in:
2026-05-07 13:43:53 -04:00
parent 918136aae2
commit 6e417312f9
9 changed files with 74 additions and 47 deletions

View File

@@ -6,7 +6,7 @@ using Socialize;
using Socialize.Api.Infrastructure.BlobStorage.Configuration;
using Socialize.Api.Infrastructure.BlobStorage.Services;
using Socialize.Api.Infrastructure;
using Socialize.Api.Infrastructure.Development;
using Socialize.Api.Infrastructure.TestData;
using Socialize.Api.Modules.Approvals;
using Socialize.Api.Modules.Assets;
using Socialize.Api.Modules.Channels;
@@ -23,6 +23,7 @@ using Socialize.Api.Modules.Workspaces;
var builder = WebApplication.CreateBuilder(args);
bool seedTestData = args.Any(arg => string.Equals(arg, "seed-testdata", StringComparison.OrdinalIgnoreCase));
string? vaultUri = Environment.GetEnvironmentVariable("VaultUri");
if (!string.IsNullOrWhiteSpace(vaultUri))
@@ -78,6 +79,25 @@ builder.AddCalendarIntegrationsModule();
var app = builder.Build();
if (seedTestData)
{
if (app.Environment.IsProduction()
&& !string.Equals(
Environment.GetEnvironmentVariable("CONFIRM_PRODUCTION_SEED"),
"true",
StringComparison.Ordinal))
{
throw new InvalidOperationException(
"Refusing to seed test data in Production without CONFIRM_PRODUCTION_SEED=true.");
}
await app.UseAppDataAsync();
await app.UseIdentityModuleAsync();
await app.Services.SeedTestDataAsync();
Console.WriteLine("Seeded test data.");
return;
}
app.UseForwardedHeaders(
new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedProto }
);
@@ -90,7 +110,6 @@ app.UseAuthorization();
// Initialize and seed the db.
await app.UseAppDataAsync();
await app.UseIdentityModuleAsync();
await app.UseDevelopmentSeedAsync();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())