From 4204847c398dc941882efeeebae18f242471efe4 Mon Sep 17 00:00:00 2001 From: Brian Bicknell Date: Mon, 3 Nov 2025 09:20:20 -0500 Subject: [PATCH] Cleaned up various fixtures. Skip publish-image for now. --- .gitea/workflows/ci.yml | 2 +- .../Fixtures/CircleSearchProviderFixture.cs | 59 +----- .../Fixtures/CreatorSearchProviderFixture.cs | 56 +----- JSMR.Tests/Fixtures/MariaDbClone.cs | 36 ++-- JSMR.Tests/Fixtures/SearchProviderFixture.cs | 69 ++----- .../Fixtures/TagSearchProviderFixture.cs | 64 +------ .../VoiceWorkSearchProviderFixture.cs | 177 +----------------- .../Ingestion/Japanese/IngestionTestsBase.cs | 7 - .../Integration/CircleSearchProviderTests.cs | 2 +- .../Integration/CreatorSearchProviderTests.cs | 2 +- .../Integration/TagSearchProviderTests.cs | 2 +- .../VoiceWorkSearchProviderTests.cs | 2 +- 12 files changed, 45 insertions(+), 433 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 8e3722e..4779f66 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -6,7 +6,6 @@ on: jobs: build-test: - if: ${{ false }} # disabled for now runs-on: [self-hosted, linux, x64, docker] container: image: ghcr.io/catthehacker/ubuntu:act-latest @@ -30,6 +29,7 @@ jobs: - run: dotnet test --configuration Release --no-build --logger "trx;LogFileName=test-results.trx" publish-image: + if: ${{ false }} # disabled for now runs-on: [self-hosted, linux, x64, docker] container: image: ghcr.io/catthehacker/ubuntu:act-latest diff --git a/JSMR.Tests/Fixtures/CircleSearchProviderFixture.cs b/JSMR.Tests/Fixtures/CircleSearchProviderFixture.cs index 6aac77c..ddccec2 100644 --- a/JSMR.Tests/Fixtures/CircleSearchProviderFixture.cs +++ b/JSMR.Tests/Fixtures/CircleSearchProviderFixture.cs @@ -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(); - } - } } \ No newline at end of file diff --git a/JSMR.Tests/Fixtures/CreatorSearchProviderFixture.cs b/JSMR.Tests/Fixtures/CreatorSearchProviderFixture.cs index af79f0b..d4fead4 100644 --- a/JSMR.Tests/Fixtures/CreatorSearchProviderFixture.cs +++ b/JSMR.Tests/Fixtures/CreatorSearchProviderFixture.cs @@ -1,20 +1,11 @@ using JSMR.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; namespace JSMR.Tests.Fixtures; -public class CreatorSearchProviderFixture : MariaDbFixture +public sealed class CreatorSearchProviderFixture(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) - { - if (await context.Tags.AnyAsync()) - return; - context.Creators.AddRange( new() { CreatorId = 1, Name = "John Smith" }, new() { CreatorId = 2, Name = "John Doe", Favorite = true }, @@ -23,47 +14,4 @@ public class CreatorSearchProviderFixture : MariaDbFixture await context.SaveChangesAsync(); } -} - - -public sealed class CreatorSearchProviderFixture2(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) - { - if (await context.Tags.AnyAsync()) - return; - - context.Creators.AddRange( - new() { CreatorId = 1, Name = "John Smith" }, - new() { CreatorId = 2, Name = "John Doe", Favorite = true }, - new() { CreatorId = 3, Name = "Jane Doe", Blacklisted = true } - ); - - await context.SaveChangesAsync(); - } - - public async ValueTask DisposeAsync() - { - if (DbContext is not null) - { - await DbContext.DisposeAsync(); - } - } } \ No newline at end of file diff --git a/JSMR.Tests/Fixtures/MariaDbClone.cs b/JSMR.Tests/Fixtures/MariaDbClone.cs index e4fb656..9423c69 100644 --- a/JSMR.Tests/Fixtures/MariaDbClone.cs +++ b/JSMR.Tests/Fixtures/MariaDbClone.cs @@ -8,19 +8,18 @@ namespace JSMR.Tests.Fixtures; public static class MariaDbClone { public static async Task CreateTemplateAsync( - string rootConn, + string rootConnectionString, string templateDbName, Func? seedAsync = null) { - await using var root = new MySqlConnection(rootConn); + await using MySqlConnection root = new(rootConnectionString); await root.OpenAsync(); await ExecAsync(root, $"DROP DATABASE IF EXISTS `{templateDbName}`;"); await ExecAsync(root, $"CREATE DATABASE `{templateDbName}` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"); - // Run EF once to build schema and seed - var templateConn = new MySqlConnectionStringBuilder(rootConn) { Database = templateDbName }.ConnectionString; - await using var ctx = AppDb(templateConn); + var templateConn = new MySqlConnectionStringBuilder(rootConnectionString) { Database = templateDbName }.ConnectionString; + await using var ctx = CreateAppDbContext(templateConn); await ctx.Database.EnsureCreatedAsync(); if (seedAsync != null) @@ -28,18 +27,18 @@ public static class MariaDbClone } public static async Task CloneFromTemplateAsync( - string rootConn, + string rootConnectionString, string templateDbName, - string newDbName, Func? seed = null) { - var newConnStr = new MySqlConnectionStringBuilder(rootConn) { Database = newDbName }.ConnectionString; + var databaseName = $"t_{DateTime.UtcNow:yyyyMMddHHmmss}_{Guid.NewGuid():N}"; + var connectionString = new MySqlConnectionStringBuilder(rootConnectionString) { Database = databaseName }.ConnectionString; - await using var root = new MySqlConnection(rootConn); + await using var root = new MySqlConnection(rootConnectionString); await root.OpenAsync(); // Create target DB - await ExecAsync(root, $"CREATE DATABASE `{newDbName}` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"); + await ExecAsync(root, $"CREATE DATABASE `{databaseName}` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"); // Disable FK checks while recreating schema & loading data await ExecAsync(root, $"SET SESSION sql_log_bin = 0;"); // avoid binlog noise (optional) @@ -52,23 +51,20 @@ public static class MariaDbClone { var createTable = await ShowCreateTableAsync(root, templateDbName, table); // Run DDL in the new DB (the CREATE statement itself doesn't include db name) - await ExecAsync(root, $"USE `{newDbName}`; {createTable};"); + await ExecAsync(root, $"USE `{databaseName}`; {createTable};"); } // 2) Copy data foreach (var table in tables) { - var sql = $"INSERT INTO `{newDbName}`.`{table}` SELECT * FROM `{templateDbName}`.`{table}`;"; + var sql = $"INSERT INTO `{databaseName}`.`{table}` SELECT * FROM `{templateDbName}`.`{table}`;"; await ExecAsync(root, sql); } await ExecAsync(root, $"SET SESSION foreign_key_checks = 1;"); await ExecAsync(root, $"SET SESSION sql_log_bin = 1;"); - // Ready-to-use EF context for the cloned DB - //return AppDb(newConnStr); - - AppDbContext dbContext = AppDb(newConnStr); + AppDbContext dbContext = CreateAppDbContext(connectionString); if (seed != null) await seed(dbContext); @@ -76,14 +72,14 @@ public static class MariaDbClone return dbContext; } - private static AppDbContext AppDb(string connStr) + private static AppDbContext CreateAppDbContext(string connectionString) { - var opts = new DbContextOptionsBuilder() - .UseMySql(connStr, ServerVersion.AutoDetect(connStr), o => o.EnableRetryOnFailure()) + var options = new DbContextOptionsBuilder() + .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), o => o.EnableRetryOnFailure()) .EnableSensitiveDataLogging() .Options; - return new AppDbContext(opts); + return new AppDbContext(options); } private static async Task> GetTableNamesAsync(MySqlConnection conn, string db) diff --git a/JSMR.Tests/Fixtures/SearchProviderFixture.cs b/JSMR.Tests/Fixtures/SearchProviderFixture.cs index 660f351..b928da8 100644 --- a/JSMR.Tests/Fixtures/SearchProviderFixture.cs +++ b/JSMR.Tests/Fixtures/SearchProviderFixture.cs @@ -1,65 +1,28 @@ using JSMR.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; namespace JSMR.Tests.Fixtures; -public class SearchProviderFixture : MariaDbFixture +public abstract class SearchProviderFixture(MariaDbContainerFixture container) : IAsyncLifetime { - protected override async Task OnInitializedAsync(AppDbContext context) + public AppDbContext? DbContext { get; private set; } + + public async ValueTask InitializeAsync() { - await SeedAsync(context); + DbContext = await MariaDbClone.CloneFromTemplateAsync( + container.RootConnectionString, + container.TemplateDbName, + seed: SeedAsync); } - private static async Task SeedAsync(AppDbContext context) + protected abstract Task SeedAsync(AppDbContext context); + + public async ValueTask DisposeAsync() { - // Make seeding idempotent (quick existence check) - if (await context.Circles.AnyAsync()) - return; + if (DbContext is not null) + { + await DbContext.DisposeAsync(); + } - 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" } - ); - - //context.VoiceWorks.AddRange( - // new() { VoiceWorkId = 1, CircleId = 1, ProductId = "RJ0000001", ProductName = "Today Sounds", Description = "An average product.", Status = (byte)VoiceWorkStatus.Available }, - // new() { VoiceWorkId = 2, CircleId = 2, ProductId = "RJ0000002", ProductName = "Super Comfy ASMR", Description = "An amazing product!", Status = (byte)VoiceWorkStatus.NewRelease }, - // new() { VoiceWorkId = 4, CircleId = 3, ProductId = "RJ0000003", ProductName = "Low Effort", Description = "A bad product.", Status = (byte)VoiceWorkStatus.Available }, - // new() { VoiceWorkId = 5, CircleId = 1, ProductId = "RJ0000004", ProductName = "Tomorrow Sounds", Description = "A average upcoming product.", Status = (byte)VoiceWorkStatus.Upcoming }, - // new() { VoiceWorkId = 6, CircleId = 2, ProductId = "RJ0000005", ProductName = "Super Comfy ASMR+", Description = "All your favorite sounds, plus more!", Status = (byte)VoiceWorkStatus.NewAndUpcoming } - //); - - context.Tags.AddRange( - new() { TagId = 1, Name = "ASMR" }, - new() { TagId = 2, Name = "OL" }, - new() { TagId = 3, Name = "ほのぼの" }, - new() { TagId = 4, Name = "エルフ/妖精" }, - new() { TagId = 5, Name = "ツンデレ", Favorite = true }, - new() { TagId = 6, Name = "オールハッピー" }, - new() { TagId = 7, Name = "ギャル" }, - new() { TagId = 8, Name = "メイド" } - ); - - context.EnglishTags.AddRange( - new() { EnglishTagId = 1, TagId = 1, Name = "ASMR" }, - new() { EnglishTagId = 2, TagId = 2, Name = "Office Lady" }, - new() { EnglishTagId = 3, TagId = 3, Name = "Heartwarming" }, - new() { EnglishTagId = 4, TagId = 4, Name = "Elf / Fairy" }, - new() { EnglishTagId = 5, TagId = 5, Name = "Tsundere" }, - new() { EnglishTagId = 6, TagId = 6, Name = "All Happy" }, - new() { EnglishTagId = 7, TagId = 7, Name = "Gal" }, - new() { EnglishTagId = 8, TagId = 8, Name = "Maid" } - ); - - context.Creators.AddRange( - new() { CreatorId = 1, Name = "陽向葵ゅか", Favorite = true }, - new() { CreatorId = 2, Name = "秋野かえで" }, - new() { CreatorId = 3, Name = "柚木つばめ" }, - new() { CreatorId = 4, Name = "逢坂成美" }, - new() { CreatorId = 5, Name = "山田じぇみ子", Blacklisted = true } - ); - - await context.SaveChangesAsync(); + GC.SuppressFinalize(this); } } \ No newline at end of file diff --git a/JSMR.Tests/Fixtures/TagSearchProviderFixture.cs b/JSMR.Tests/Fixtures/TagSearchProviderFixture.cs index df2f02c..160cee6 100644 --- a/JSMR.Tests/Fixtures/TagSearchProviderFixture.cs +++ b/JSMR.Tests/Fixtures/TagSearchProviderFixture.cs @@ -1,23 +1,11 @@ using JSMR.Infrastructure.Data; -using JSMR.Tests.Ingestion; -using Microsoft.EntityFrameworkCore; -using MySqlConnector; -using Testcontainers.MariaDb; namespace JSMR.Tests.Fixtures; -public class TagSearchProviderFixture : MariaDbFixture +public sealed class TagSearchProviderFixture(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) - { - if (await context.Tags.AnyAsync()) - return; - context.Tags.AddRange( new() { TagId = 1, Name = "OL" }, new() { TagId = 2, Name = "ほのぼの", Favorite = true }, @@ -32,52 +20,4 @@ public class TagSearchProviderFixture : MariaDbFixture await context.SaveChangesAsync(); } -} - -public sealed class TagSearchProviderFixture2(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) - { - if (await context.Tags.AnyAsync()) - return; - - context.Tags.AddRange( - new() { TagId = 1, Name = "OL" }, - new() { TagId = 2, Name = "ほのぼの", Favorite = true }, - new() { TagId = 3, Name = "ツンデレ", Blacklisted = true } - ); - - context.EnglishTags.AddRange( - new() { EnglishTagId = 1, TagId = 1, Name = "Office Lady" }, - new() { EnglishTagId = 2, TagId = 2, Name = "Heartwarming" }, - new() { EnglishTagId = 3, TagId = 3, Name = "Tsundere" } - ); - - await context.SaveChangesAsync(); - } - - public async ValueTask DisposeAsync() - { - if (DbContext is not null) - { - await DbContext.DisposeAsync(); - } - } } \ No newline at end of file diff --git a/JSMR.Tests/Fixtures/VoiceWorkSearchProviderFixture.cs b/JSMR.Tests/Fixtures/VoiceWorkSearchProviderFixture.cs index 70ebff3..7bb53ed 100644 --- a/JSMR.Tests/Fixtures/VoiceWorkSearchProviderFixture.cs +++ b/JSMR.Tests/Fixtures/VoiceWorkSearchProviderFixture.cs @@ -1,22 +1,12 @@ using JSMR.Domain.Enums; using JSMR.Infrastructure.Data; -using JSMR.Tests.Ingestion; -using Microsoft.EntityFrameworkCore; namespace JSMR.Tests.Fixtures; -public class VoiceWorkSearchProviderFixture : MariaDbFixture +public sealed class VoiceWorkSearchProviderFixture(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) - { - if (await context.VoiceWorks.AnyAsync()) - return; - context.Circles.AddRange( new() { CircleId = 1, Name = "Good Dreams", MakerId = "RG00001" }, new() { CircleId = 2, Name = "Sweet Dreams", Favorite = true, MakerId = "RG00002" }, @@ -69,27 +59,6 @@ public class VoiceWorkSearchProviderFixture : MariaDbFixture new() { VoiceWorkId = 3, TagId = 5 }, // Tsundere new() { VoiceWorkId = 3, TagId = 9 } // Non-Fiction / Narrative - //new() { VoiceWorkId = 3, TagId = 1 }, - //new() { VoiceWorkId = 3, TagId = 1 }, - //new() { VoiceWorkId = 3, TagId = 1 }, - //new() { VoiceWorkId = 3, TagId = 1 }, - //new() { VoiceWorkId = 3, TagId = 1 }, - - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - - //new() { VoiceWorkId = 5, TagId = 5 } // Tsundere - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 } ); context.Creators.AddRange( @@ -125,146 +94,4 @@ public class VoiceWorkSearchProviderFixture : MariaDbFixture await context.SaveChangesAsync(); } -} - -public sealed class VoiceWorkSearchProviderFixture2(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) - { - if (await context.VoiceWorks.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" } - ); - - context.VoiceWorks.AddRange( - new() { VoiceWorkId = 1, CircleId = 1, ProductId = "RJ0000001", ProductName = "Today Sounds", Description = "An average product.", Status = (byte)VoiceWorkStatus.Available, SalesDate = new(2025, 1, 1), Downloads = 500, WishlistCount = 750, StarRating = 35 }, - new() { VoiceWorkId = 2, CircleId = 2, ProductId = "RJ0000002", ProductName = "Super Comfy ASMR", Description = "An amazing product!", Status = (byte)VoiceWorkStatus.NewRelease, SalesDate = new(2025, 1, 3), Downloads = 5000, WishlistCount = 12000, StarRating = 50, Favorite = true }, - new() { VoiceWorkId = 3, CircleId = 3, ProductId = "RJ0000003", ProductName = "Low Effort", Description = "A bad product.", Status = (byte)VoiceWorkStatus.Available, SalesDate = new(2025, 1, 2), Downloads = 50, WishlistCount = 100, StarRating = 20 }, - new() { VoiceWorkId = 4, CircleId = 1, ProductId = "RJ0000004", ProductName = "Tomorrow Sounds", Description = "A average upcoming product.", Status = (byte)VoiceWorkStatus.Upcoming, ExpectedDate = new(2025, 1, 1), WishlistCount = 300 }, - new() { VoiceWorkId = 5, CircleId = 2, ProductId = "RJ0000005", ProductName = "Super Comfy ASMR+", Description = "All your favorite sounds, plus more!", Status = (byte)VoiceWorkStatus.NewAndUpcoming, ExpectedDate = new(2025, 1, 11), WishlistCount = 10000 } - ); - - context.Tags.AddRange( - new() { TagId = 1, Name = "ASMR" }, - new() { TagId = 2, Name = "OL" }, - new() { TagId = 3, Name = "ほのぼの" }, - new() { TagId = 4, Name = "エルフ/妖精" }, - new() { TagId = 5, Name = "ツンデレ", Favorite = true }, - new() { TagId = 6, Name = "オールハッピー" }, - new() { TagId = 7, Name = "ギャル" }, - new() { TagId = 8, Name = "メイド" }, - new() { TagId = 9, Name = "ノンフィクション/体験談", Blacklisted = true } - ); - - context.EnglishTags.AddRange( - new() { EnglishTagId = 1, TagId = 1, Name = "ASMR" }, - new() { EnglishTagId = 2, TagId = 2, Name = "Office Lady" }, - new() { EnglishTagId = 3, TagId = 3, Name = "Heartwarming" }, - new() { EnglishTagId = 4, TagId = 4, Name = "Elf / Fairy" }, - new() { EnglishTagId = 5, TagId = 5, Name = "Tsundere" }, - new() { EnglishTagId = 6, TagId = 6, Name = "All Happy" }, - new() { EnglishTagId = 7, TagId = 7, Name = "Gal" }, - new() { EnglishTagId = 8, TagId = 8, Name = "Maid" }, - new() { EnglishTagId = 9, TagId = 9, Name = "Non-Fiction / Narrative" } - ); - - context.VoiceWorkTags.AddRange( - new() { VoiceWorkId = 1, TagId = 1 }, // ASMR - new() { VoiceWorkId = 1, TagId = 2 }, // Office Lady - - new() { VoiceWorkId = 2, TagId = 1 }, // ASMR - new() { VoiceWorkId = 2, TagId = 3 }, // Heartwarming - new() { VoiceWorkId = 2, TagId = 4 }, // Elf / Fairy - new() { VoiceWorkId = 2, TagId = 5 }, // Tsundere - new() { VoiceWorkId = 2, TagId = 6 }, // All Happy - new() { VoiceWorkId = 2, TagId = 7 }, // Gal - new() { VoiceWorkId = 2, TagId = 8 }, // Maid - - new() { VoiceWorkId = 3, TagId = 5 }, // Tsundere - new() { VoiceWorkId = 3, TagId = 9 } // Non-Fiction / Narrative - //new() { VoiceWorkId = 3, TagId = 1 }, - //new() { VoiceWorkId = 3, TagId = 1 }, - //new() { VoiceWorkId = 3, TagId = 1 }, - //new() { VoiceWorkId = 3, TagId = 1 }, - //new() { VoiceWorkId = 3, TagId = 1 }, - - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - //new() { VoiceWorkId = 4, TagId = 1 }, - - //new() { VoiceWorkId = 5, TagId = 5 } // Tsundere - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 }, - //new() { VoiceWorkId = 5, TagId = 1 } - ); - - context.Creators.AddRange( - new() { CreatorId = 1, Name = "陽向葵ゅか", Favorite = true }, - new() { CreatorId = 2, Name = "秋野かえで" }, - new() { CreatorId = 3, Name = "柚木つばめ" }, - new() { CreatorId = 4, Name = "逢坂成美" }, - new() { CreatorId = 5, Name = "山田じぇみ子", Blacklisted = true } - ); - - context.VoiceWorkCreators.AddRange( - new() { VoiceWorkId = 1, CreatorId = 2 }, // 秋野かえで - - new() { VoiceWorkId = 2, CreatorId = 1 }, // 陽向葵ゅか - - new() { VoiceWorkId = 3, CreatorId = 5 }, // 山田じぇみ子 - new() { VoiceWorkId = 3, CreatorId = 1 }, // 陽向葵ゅか - - new() { VoiceWorkId = 4, CreatorId = 3 }, // 柚木つばめ - - new() { VoiceWorkId = 5, CreatorId = 1 }, // 陽向葵ゅか - new() { VoiceWorkId = 5, CreatorId = 4 } // 逢坂成美 - ); - - // - context.VoiceWorkSearches.AddRange( - new() { VoiceWorkId = 1, SearchText = "RJ0000001 RG00001 Good Dreams Today Sounds An average product. ASMR Office Lady" }, - new() { VoiceWorkId = 2, SearchText = "RJ0000002 RG00002 Sweet Dreams Super Comfy ASMR An amazing product! ASMR Heartwarming Elf / Fairy Tsundere All Happy Gal Maid" }, - new() { VoiceWorkId = 3, SearchText = "RJ0000003 RG00003 Nightmare Fuel Low Effort A bad product." }, - new() { VoiceWorkId = 4, SearchText = "RJ0000004 RG00001 Good Dreams Tomorrow Sounds A average upcoming product." }, - new() { VoiceWorkId = 5, SearchText = "RJ0000005 RG00002 Sweet Dreams Super Comfy ASMR+ All your favorite sounds, plus more!" } - ); - - await context.SaveChangesAsync(); - } - - public async ValueTask DisposeAsync() - { - if (DbContext is not null) - { - await DbContext.DisposeAsync(); - } - } } \ No newline at end of file diff --git a/JSMR.Tests/Ingestion/Japanese/IngestionTestsBase.cs b/JSMR.Tests/Ingestion/Japanese/IngestionTestsBase.cs index c7e029b..e7ddeb2 100644 --- a/JSMR.Tests/Ingestion/Japanese/IngestionTestsBase.cs +++ b/JSMR.Tests/Ingestion/Japanese/IngestionTestsBase.cs @@ -14,16 +14,9 @@ public abstract class IngestionTestsBase(MariaDbContainerFixture container) { protected async Task GetAppDbContextAsync() { - //return await MariaTestDb.CreateIsolatedAsync( - // container.RootConnectionString, - // seed: VoiceWorkIngestionSeedData.SeedAsync); - - var newDb = $"t_{DateTime.UtcNow:yyyyMMddHHmmss}_{Guid.NewGuid():N}"; - return await MariaDbClone.CloneFromTemplateAsync( container.RootConnectionString, container.TemplateDbName, - newDbName: newDb, seed: VoiceWorkIngestionSeedData.SeedAsync); } diff --git a/JSMR.Tests/Integration/CircleSearchProviderTests.cs b/JSMR.Tests/Integration/CircleSearchProviderTests.cs index 32b083f..6d4925d 100644 --- a/JSMR.Tests/Integration/CircleSearchProviderTests.cs +++ b/JSMR.Tests/Integration/CircleSearchProviderTests.cs @@ -8,7 +8,7 @@ using Shouldly; namespace JSMR.Tests.Integration; -public class CircleSearchProviderTests(CircleSearchProviderFixture2 fixture) : IClassFixture +public class CircleSearchProviderTests(CircleSearchProviderFixture fixture) : IClassFixture { [Fact] public async Task Filter_None() diff --git a/JSMR.Tests/Integration/CreatorSearchProviderTests.cs b/JSMR.Tests/Integration/CreatorSearchProviderTests.cs index 4d2ad25..5996c95 100644 --- a/JSMR.Tests/Integration/CreatorSearchProviderTests.cs +++ b/JSMR.Tests/Integration/CreatorSearchProviderTests.cs @@ -7,7 +7,7 @@ using Shouldly; namespace JSMR.Tests.Integration; -public class CreatorSearchProviderTests(CreatorSearchProviderFixture2 fixture) : IClassFixture +public class CreatorSearchProviderTests(CreatorSearchProviderFixture fixture) : IClassFixture { [Fact] public async Task Filter_None_Sort_Name_Ascending() diff --git a/JSMR.Tests/Integration/TagSearchProviderTests.cs b/JSMR.Tests/Integration/TagSearchProviderTests.cs index 9733a63..c7d6f93 100644 --- a/JSMR.Tests/Integration/TagSearchProviderTests.cs +++ b/JSMR.Tests/Integration/TagSearchProviderTests.cs @@ -7,7 +7,7 @@ using Shouldly; namespace JSMR.Tests.Integration; -public class TagSearchProviderTests(TagSearchProviderFixture2 fixture) : IClassFixture +public class TagSearchProviderTests(TagSearchProviderFixture fixture) : IClassFixture { [Fact] public async Task Filter_None_Sort_Name() diff --git a/JSMR.Tests/Integration/VoiceWorkSearchProviderTests.cs b/JSMR.Tests/Integration/VoiceWorkSearchProviderTests.cs index dc4fe58..faf0ab9 100644 --- a/JSMR.Tests/Integration/VoiceWorkSearchProviderTests.cs +++ b/JSMR.Tests/Integration/VoiceWorkSearchProviderTests.cs @@ -7,7 +7,7 @@ using Shouldly; namespace JSMR.Tests.Integration; -public class VoiceWorkSearchProviderTests(VoiceWorkSearchProviderFixture2 fixture) : IClassFixture +public class VoiceWorkSearchProviderTests(VoiceWorkSearchProviderFixture fixture) : IClassFixture { private static VoiceWorkSearchProvider InitializeVoiceWorkSearchProvider(AppDbContext context) {