Files
jellyfin-multilang/tests/Jellyfin.Plugin.Multilang.Tests/TranslationStoreBatchTests.cs
T
ajp_anton e36775f1a3 Release 0.2.5: harden proxy and streamline metadata fetching
Remove obsolete rule formats, batch SQLite work, preserve artwork source URLs, and coordinate refresh workers with maintenance. Add regression coverage and document backup format changes.
2026-09-09 01:18:43 +00:00

34 lines
1.5 KiB
C#

using System.Diagnostics;
using Jellyfin.Plugin.Multilang.Data;
using Jellyfin.Plugin.Multilang.Services.Refresh;
using Xunit.Abstractions;
namespace Jellyfin.Plugin.Multilang.Tests;
public sealed class TranslationStoreBatchTests(ITestOutputHelper output)
{
[Fact]
public void BatchFactsLookupMatchesIndividualReads()
{
var root = TestPaths.CreateRoot();
try
{
var store = new TranslationStore(new TestApplicationPaths(root));
var ids = Enumerable.Range(0, 100).Select(index => index.ToString()).ToArray();
foreach (var id in ids)
store.SaveMetadata(new(id, id, "movie", RefreshWorkClass.Movies, 0, 0, null, "Movie"), "fi",
new("Title", "Overview", "Tagline", "Title", "fi", [], [], [], []), new("scope", 1, true), true);
var timer = Stopwatch.StartNew();
var individual = ids.Select(id => store.GetFacts(id)!).ToArray();
var separateMs = timer.Elapsed.TotalMilliseconds;
timer.Restart();
var batch = store.GetFactsForItems(ids.Concat(ids));
var batchMs = timer.Elapsed.TotalMilliseconds;
Assert.Equal(individual, ids.Select(id => batch[id]));
Assert.Equal(ids.Length, batch.Count);
output.WriteLine($"100 individual fact reads: {separateMs:F2} ms; one batched read: {batchMs:F2} ms. Timing is diagnostic, not a pass condition.");
}
finally { TestPaths.DeleteRoot(root); }
}
}