From bc42ff4b281e86323978f7c94c689e5636c91c4e Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Sat, 12 Sep 2026 21:36:09 +1000 Subject: [PATCH] test(db): drop a leftover test database before recreating it A server handed in through JELLYFIN_TEST_POSTGRES outlives the run, so a second run finds the databases the first one created. Also name the failures in Jellyfin.Database.Tests.PostgreSQL the CI step steps around. --- .woodpecker/ci.yaml | 3 ++- .../Migrations/PostgreSqlTestServer.cs | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.woodpecker/ci.yaml b/.woodpecker/ci.yaml index d19681d07f..347becf386 100644 --- a/.woodpecker/ci.yaml +++ b/.woodpecker/ci.yaml @@ -46,7 +46,8 @@ steps: # the ReadWriteOnce workspace volume into service pods and schedules them on another node. # Its data directory lives on the step's ephemeral storage, not on the workspace volume. # Scoped to Jellyfin.Server.Tests: the three classes in Jellyfin.Database.Tests.PostgreSQL still - # start their own container, and two of their tests fail on main for unrelated reasons. + # start their own container, and PostgreSqlProviderTests already fails on main - on an EF 10 + # scalar query and on its own data - which a third test in the class then inherits. - name: postgres-migration-chain image: mcr.microsoft.com/dotnet/sdk:10.0 depends_on: diff --git a/tests/Jellyfin.Server.Tests/Migrations/PostgreSqlTestServer.cs b/tests/Jellyfin.Server.Tests/Migrations/PostgreSqlTestServer.cs index d7a6196aca..7a399a5bd0 100644 --- a/tests/Jellyfin.Server.Tests/Migrations/PostgreSqlTestServer.cs +++ b/tests/Jellyfin.Server.Tests/Migrations/PostgreSqlTestServer.cs @@ -65,6 +65,12 @@ public sealed class PostgreSqlTestServer : IAsyncDisposable public async Task CreateDatabaseAsync(string name, CancellationToken cancellationToken) { await using var adminDataSource = new NpgsqlDataSourceBuilder(ConnectionString).Build(); + + // A server handed in through the environment outlives the run, so a second run finds the + // databases the first one left behind. + await using var drop = adminDataSource.CreateCommand($"DROP DATABASE IF EXISTS {name}"); + await drop.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false); + await using var command = adminDataSource.CreateCommand($"CREATE DATABASE {name}"); await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);