diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-09-06 07:46:18 +0200 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-09-06 07:54:11 +0200 |
| commit | ca90347dc242e7dc5e49e6fb8938e084564ab2de (patch) | |
| tree | faa5fcbfe6b503b721de3807ce80e26bcaa2d67c /tests/Jellyfin.Server.Tests/Migrations/CodeMigrationTests.cs | |
| parent | 9c259027dfa6d799dab282fd2ee0315e572b4a7c (diff) | |
Resolve migration routine loggers from the application container
Diffstat (limited to 'tests/Jellyfin.Server.Tests/Migrations/CodeMigrationTests.cs')
| -rw-r--r-- | tests/Jellyfin.Server.Tests/Migrations/CodeMigrationTests.cs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/Jellyfin.Server.Tests/Migrations/CodeMigrationTests.cs b/tests/Jellyfin.Server.Tests/Migrations/CodeMigrationTests.cs index 68dd4486be..3bd8581a5f 100644 --- a/tests/Jellyfin.Server.Tests/Migrations/CodeMigrationTests.cs +++ b/tests/Jellyfin.Server.Tests/Migrations/CodeMigrationTests.cs @@ -20,7 +20,6 @@ public class CodeMigrationTests .RegisterStartupLogger() .AddSingleton<ApplicationSingleton>() .AddTransient<MigrationTransient>(); - services.AddSingleton(services); await using var serviceProvider = services.BuildServiceProvider(); var applicationSingleton = serviceProvider.GetRequiredService<ApplicationSingleton>(); @@ -44,6 +43,29 @@ public class CodeMigrationTests Assert.Same(logger.Topic, performed.Logger.Topic); } + [Fact] + public async Task Perform_DoesNotLeakTheMigrationTopic() + { + var services = new ServiceCollection() + .AddLogging() + .RegisterStartupLogger() + .AddSingleton<ApplicationSingleton>() + .AddTransient<MigrationTransient>(); + + await using var serviceProvider = services.BuildServiceProvider(); + var logger = new StartupLogger(NullLogger.Instance).BeginGroup($"Test migration"); + + var migration = new CodeMigration( + typeof(TestMigration), + new JellyfinMigrationAttribute("2026-09-05T10:00:00", nameof(TestMigration)), + null); + await migration.Perform(serviceProvider, logger, CancellationToken.None); + + // The topic belongs to the migration that ran, so loggers resolved afterwards must not still write into it. + Assert.Null(serviceProvider.GetRequiredService<IStartupLogger<CodeMigrationTests>>().Topic); + Assert.Null(new StartupLogger(NullLogger.Instance).Topic); + } + private sealed class ApplicationSingleton : IDisposable { public bool IsDisposed { get; private set; } |
