up
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Npgsql;
|
||||
@@ -75,7 +76,7 @@ public sealed class PostgresFixture : IAsyncDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs migrations for the test schema.
|
||||
/// Runs migrations for the test schema from filesystem path.
|
||||
/// </summary>
|
||||
/// <param name="migrationsPath">Path to migration SQL files.</param>
|
||||
/// <param name="moduleName">Module name for logging.</param>
|
||||
@@ -94,6 +95,41 @@ public sealed class PostgresFixture : IAsyncDisposable
|
||||
await runner.RunAsync(migrationsPath, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs migrations for the test schema from embedded resources in an assembly.
|
||||
/// </summary>
|
||||
/// <param name="assembly">Assembly containing embedded migration resources.</param>
|
||||
/// <param name="moduleName">Module name for logging.</param>
|
||||
/// <param name="resourcePrefix">Optional prefix to filter resources.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
public async Task RunMigrationsFromAssemblyAsync(
|
||||
Assembly assembly,
|
||||
string moduleName,
|
||||
string? resourcePrefix = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var runner = new MigrationRunner(
|
||||
_connectionString,
|
||||
_schemaName,
|
||||
moduleName,
|
||||
_logger);
|
||||
|
||||
await runner.RunFromAssemblyAsync(assembly, resourcePrefix, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs migrations for the test schema from embedded resources using a type from the assembly.
|
||||
/// </summary>
|
||||
/// <typeparam name="TAssemblyMarker">Type from the assembly containing migrations.</typeparam>
|
||||
/// <param name="moduleName">Module name for logging.</param>
|
||||
/// <param name="resourcePrefix">Optional prefix to filter resources.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
public Task RunMigrationsFromAssemblyAsync<TAssemblyMarker>(
|
||||
string moduleName,
|
||||
string? resourcePrefix = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
=> RunMigrationsFromAssemblyAsync(typeof(TAssemblyMarker).Assembly, moduleName, resourcePrefix, cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Executes raw SQL for test setup.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user