Expand integration coverage and fix settings UI

This commit is contained in:
ajp_anton
2026-07-21 00:42:44 +00:00
parent 25088ce91d
commit 094d5ad9f0
26 changed files with 1665 additions and 66 deletions
@@ -0,0 +1,64 @@
using MediaBrowser.Common.Configuration;
namespace Jellyfin.Plugin.Multilang.Tests;
internal sealed class TestApplicationPaths(string root) : IApplicationPaths
{
public string ProgramDataPath { get; } = root;
public string WebPath { get; } = Path.Combine(root, "web");
public string ProgramSystemPath { get; } = Path.Combine(root, "system");
public string DataPath { get; } = Path.Combine(root, "data");
public string ImageCachePath { get; } = Path.Combine(root, "images");
public string PluginsPath { get; } = Path.Combine(root, "plugins");
public string PluginConfigurationsPath { get; } = Path.Combine(root, "plugin-configs");
public string LogDirectoryPath { get; } = Path.Combine(root, "logs");
public string ConfigurationDirectoryPath { get; } = Path.Combine(root, "config");
public string SystemConfigurationFilePath { get; } = Path.Combine(root, "config", "system.xml");
public string CachePath { get; } = Path.Combine(root, "cache");
public string TempDirectory { get; } = Path.Combine(root, "temp");
public string VirtualDataPath { get; } = "%AppDataPath%";
public string TrickplayPath { get; } = Path.Combine(root, "trickplay");
public string BackupPath { get; } = Path.Combine(root, "backups");
public void MakeSanityCheckOrThrow()
{
}
public void CreateAndCheckMarker(string path, string marker, bool isTemporary = false)
{
}
}
internal sealed class TestHttpClientFactory(Func<HttpRequestMessage, HttpResponseMessage> responseFactory) : IHttpClientFactory
{
public List<string> Requests { get; } = [];
public HttpClient CreateClient(string name)
=> new(new TestHttpMessageHandler(request =>
{
Requests.Add(request.RequestUri?.ToString() ?? string.Empty);
return responseFactory(request);
}));
}
internal sealed class TestHttpMessageHandler(Func<HttpRequestMessage, HttpResponseMessage> responseFactory) : HttpMessageHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
=> Task.FromResult(responseFactory(request));
}
internal static class TestPaths
{
public static string CreateRoot()
{
var path = Path.Combine(Path.GetTempPath(), "multilang-test-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(path);
return path;
}
public static void DeleteRoot(string root)
{
if (Directory.Exists(root))
Directory.Delete(root, recursive: true);
}
}