aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs')
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs37
1 files changed, 22 insertions, 15 deletions
diff --git a/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs b/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs
index d9ec81a27..55bc43455 100644
--- a/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs
+++ b/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs
@@ -1,9 +1,11 @@
using System;
using System.Collections.Concurrent;
+using System.Globalization;
using System.IO;
using System.Threading;
using Emby.Server.Implementations;
-using Emby.Server.Implementations.IO;
+using Jellyfin.Server.Extensions;
+using Jellyfin.Server.Helpers;
using MediaBrowser.Common;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
@@ -11,6 +13,7 @@ using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Abstractions;
using Serilog;
using Serilog.Extensions.Logging;
@@ -30,8 +33,10 @@ namespace Jellyfin.Server.Integration.Tests
static JellyfinApplicationFactory()
{
// Perform static initialization that only needs to happen once per test-run
- Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger();
- Program.PerformStaticInitialization();
+ Log.Logger = new LoggerConfiguration()
+ .WriteTo.Console(formatProvider: CultureInfo.InvariantCulture)
+ .CreateLogger();
+ StartupHelpers.PerformStaticInitialization();
}
/// <inheritdoc/>
@@ -44,10 +49,7 @@ namespace Jellyfin.Server.Integration.Tests
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
// Specify the startup command line options
- var commandLineOpts = new StartupOptions
- {
- NoWebClient = true
- };
+ var commandLineOpts = new StartupOptions();
// Use a temporary directory for the application paths
var webHostPathRoot = Path.Combine(_testPathRoot, "test-host-" + Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
@@ -64,13 +66,13 @@ namespace Jellyfin.Server.Integration.Tests
// Create the logging config file
// TODO: We shouldn't need to do this since we are only logging to console
- Program.InitLoggingConfigFile(appPaths).GetAwaiter().GetResult();
+ StartupHelpers.InitLoggingConfigFile(appPaths).GetAwaiter().GetResult();
// Create a copy of the application configuration to use for startup
var startupConfig = Program.CreateAppConfiguration(commandLineOpts, appPaths);
ILoggerFactory loggerFactory = new SerilogLoggerFactory();
- var serviceCollection = new ServiceCollection();
+
_disposableComponents.Add(loggerFactory);
// Create the app host and initialize it
@@ -78,14 +80,19 @@ namespace Jellyfin.Server.Integration.Tests
appPaths,
loggerFactory,
commandLineOpts,
- new ConfigurationBuilder().Build(),
- new ManagedFileSystem(loggerFactory.CreateLogger<ManagedFileSystem>(), appPaths),
- serviceCollection);
+ startupConfig);
_disposableComponents.Add(appHost);
- appHost.Init();
- // Configure the web host builder
- Program.ConfigureWebHostBuilder(builder, appHost, serviceCollection, commandLineOpts, startupConfig, appPaths);
+ builder.ConfigureServices(services => appHost.Init(services))
+ .ConfigureWebHostBuilder(appHost, startupConfig, appPaths, NullLogger.Instance)
+ .ConfigureAppConfiguration((context, builder) =>
+ {
+ builder
+ .SetBasePath(appPaths.ConfigurationDirectoryPath)
+ .AddInMemoryCollection(ConfigurationOptions.DefaultConfiguration)
+ .AddEnvironmentVariables("JELLYFIN_")
+ .AddInMemoryCollection(commandLineOpts.ConvertToConfig());
+ });
}
/// <inheritdoc/>