Added logic to remove supported languages that are no longer supported, rather than just being purely additive. Added ApiClient logging.
All checks were successful
ci / build-test (push) Successful in 2m30s
ci / publish-image (push) Successful in 2m1s

This commit is contained in:
2026-03-30 23:03:53 -04:00
parent 0dd11e6351
commit adfbf654a6
6 changed files with 91 additions and 4 deletions

View File

@@ -0,0 +1,63 @@
using JSMR.Application.Scanning.Contracts;
using JSMR.Domain.Entities;
using JSMR.Domain.ValueObjects;
using JSMR.Infrastructure.Data;
using JSMR.Tests.Fixtures;
using Microsoft.EntityFrameworkCore;
using Shouldly;
namespace JSMR.Tests.Ingestion.Japanese;
public class Update_Supported_Langauge_Tests(MariaDbContainerFixture container) : JapaneseIngestionTestsBase(container)
{
[Fact]
public async Task Update_Supported_Langauge()
{
VoiceWorkIngest ingest = new()
{
MakerId = "RG1",
MakerName = "The Maker",
ProductId = "RJ1",
Title = "Title",
Description = "Description",
SupportedLanguages = [SupportedLanguage.Japanese]
};
await using AppDbContext dbContext = await GetAppDbContextAsync();
DateTime currentDateTime = TokyoLocalToUtc(2025, 01, 05, 10, 0, 0);
await UpsertAndVerify(dbContext, TokyoLocalToUtc(2025, 01, 05, 10, 0, 0), ingest, [SupportedLanguage.Japanese]);
// Add English
VoiceWorkIngest addSupportedLanguageIngest = ingest with
{
SupportedLanguages = [SupportedLanguage.Japanese, SupportedLanguage.English]
};
await UpsertAndVerify(dbContext, TokyoLocalToUtc(2025, 01, 05, 10, 0, 0), addSupportedLanguageIngest, [SupportedLanguage.Japanese, SupportedLanguage.English]);
// Remove Japanese
VoiceWorkIngest removeSupportedLanguageIngest = ingest with
{
SupportedLanguages = [SupportedLanguage.English]
};
await UpsertAndVerify(dbContext, TokyoLocalToUtc(2025, 01, 05, 10, 0, 0), removeSupportedLanguageIngest, [SupportedLanguage.English]);
}
private static async Task UpsertAndVerify(AppDbContext dbContext, DateTime dateTime, VoiceWorkIngest ingest, SupportedLanguage[] expectedSupportedLanguages)
{
await UpsertAsync(dbContext, dateTime, [ingest]);
VoiceWork? voiceWork = await dbContext.VoiceWorks
.Include(x => x.SupportedLanguages)
.SingleAsync(v => v.ProductId == ingest.ProductId, TestContext.Current.CancellationToken);
voiceWork.ShouldNotBeNull();
string[] languageCodes = [.. voiceWork.SupportedLanguages.Select(x => x.Language).OrderBy(x => x)];
string[] expectedLanguageCode = [.. expectedSupportedLanguages.Select(x => x.Code).OrderBy(x => x)];
languageCodes.ShouldBe(expectedLanguageCode);
}
}

View File

@@ -48,7 +48,7 @@ public class Update_Upcoming_With_No_Expected_Date_Tests(MariaDbContainerFixture
};
// Should be exactly the same
await UpsertAndVerify(dbContext, TokyoLocalToUtc(2025, 01, 05, 10, 0, 0), ingest, new DateTime(2025, 1, 21));
await UpsertAndVerify(dbContext, TokyoLocalToUtc(2025, 01, 05, 10, 0, 0), updatedIngest, new DateTime(2025, 1, 21));
}
private static async Task UpsertAndVerify(AppDbContext dbContext, DateTime dateTime, VoiceWorkIngest ingest, DateTime? expectedDate)