test(db): drop a leftover test database before recreating it
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/push/ci Pipeline was successful

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.
This commit is contained in:
2026-09-12 21:36:09 +10:00
parent b501ba9620
commit bc42ff4b28
2 changed files with 8 additions and 1 deletions
@@ -65,6 +65,12 @@ public sealed class PostgreSqlTestServer : IAsyncDisposable
public async Task<string> 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);