Cleaned up various fixtures. Skip publish-image for now.
Some checks failed
ci / build-test (push) Failing after 14m38s
ci / publish-image (push) Has been skipped

This commit is contained in:
2025-11-03 09:20:20 -05:00
parent 0399d5b761
commit 4204847c39
12 changed files with 45 additions and 433 deletions

View File

@@ -1,22 +1,11 @@
using JSMR.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
using Org.BouncyCastle.Asn1.Pkcs;
namespace JSMR.Tests.Fixtures;
public class CircleSearchProviderFixture : MariaDbFixture
public sealed class CircleSearchProviderFixture(MariaDbContainerFixture container) : SearchProviderFixture(container)
{
protected override async Task OnInitializedAsync(AppDbContext context)
protected override async Task SeedAsync(AppDbContext context)
{
await SeedAsync(context);
}
private static async Task SeedAsync(AppDbContext context)
{
// Make seeding idempotent (quick existence check)
if (await context.Circles.AnyAsync())
return;
context.Circles.AddRange(
new() { CircleId = 1, Name = "Good Dreams", MakerId = "RG00001" },
new() { CircleId = 2, Name = "Sweet Dreams", Favorite = true, MakerId = "RG00002" },
@@ -26,48 +15,4 @@ public class CircleSearchProviderFixture : MariaDbFixture
await context.SaveChangesAsync();
}
}
public sealed class CircleSearchProviderFixture2(MariaDbContainerFixture container) : IAsyncLifetime
{
public AppDbContext? DbContext { get; private set; }
public async ValueTask InitializeAsync()
{
//DbContext = await MariaTestDb.CreateIsolatedAsync(
// container.RootConnectionString,
// seed: SeedAsync);
var newDb = $"t_{DateTime.UtcNow:yyyyMMddHHmmss}_{Guid.NewGuid():N}";
DbContext = await MariaDbClone.CloneFromTemplateAsync(
container.RootConnectionString,
container.TemplateDbName,
newDbName: newDb,
seed: SeedAsync);
}
private static async Task SeedAsync(AppDbContext context)
{
// Make seeding idempotent (quick existence check)
if (await context.Circles.AnyAsync())
return;
context.Circles.AddRange(
new() { CircleId = 1, Name = "Good Dreams", MakerId = "RG00001" },
new() { CircleId = 2, Name = "Sweet Dreams", Favorite = true, MakerId = "RG00002" },
new() { CircleId = 3, Name = "Nightmare Fuel", Blacklisted = true, MakerId = "RG00003" },
new() { CircleId = 4, Name = "Garbage Studio", Spam = true, MakerId = "RG00004" }
);
await context.SaveChangesAsync();
}
public async ValueTask DisposeAsync()
{
if (DbContext is not null)
{
await DbContext.DisposeAsync();
}
}
}