diff --git a/src/Recyclarr.Tests/Migration/MigrationExecutorTest.cs b/src/Recyclarr.Tests/Migration/MigrationExecutorTest.cs index 12be01a9..ccde8ca1 100644 --- a/src/Recyclarr.Tests/Migration/MigrationExecutorTest.cs +++ b/src/Recyclarr.Tests/Migration/MigrationExecutorTest.cs @@ -1,10 +1,10 @@ using Autofac; +using CliFx.Infrastructure; using FluentAssertions; using NSubstitute; using NUnit.Framework; using Recyclarr.Migration; using Recyclarr.Migration.Steps; -using Serilog; namespace Recyclarr.Tests.Migration; @@ -31,7 +31,7 @@ public class MigrationExecutorTest public void Step_not_executed_if_check_returns_false() { var step = Substitute.For(); - var executor = new MigrationExecutor(new[] {step}, Substitute.For()); + var executor = new MigrationExecutor(new[] {step}, Substitute.For()); step.CheckIfNeeded().Returns(false); @@ -45,7 +45,7 @@ public class MigrationExecutorTest public void Step_executed_if_check_returns_true() { var step = Substitute.For(); - var executor = new MigrationExecutor(new[] {step}, Substitute.For()); + var executor = new MigrationExecutor(new[] {step}, Substitute.For()); step.CheckIfNeeded().Returns(true); @@ -69,7 +69,7 @@ public class MigrationExecutorTest steps[1].Order.Returns(10); steps[2].Order.Returns(30); - var executor = new MigrationExecutor(steps, Substitute.For()); + var executor = new MigrationExecutor(steps, Substitute.For()); executor.PerformAllMigrationSteps(); @@ -85,7 +85,7 @@ public class MigrationExecutorTest public void Exception_converted_to_migration_exception() { var step = Substitute.For(); - var executor = new MigrationExecutor(new[] {step}, Substitute.For()); + var executor = new MigrationExecutor(new[] {step}, Substitute.For()); step.CheckIfNeeded().Returns(true); step.When(x => x.Execute()).Throw(new ArgumentException("test message")); @@ -99,7 +99,7 @@ public class MigrationExecutorTest public void Migration_exceptions_are_not_converted() { var step = Substitute.For(); - var executor = new MigrationExecutor(new[] {step}, Substitute.For()); + var executor = new MigrationExecutor(new[] {step}, Substitute.For()); var exception = new MigrationException(new Exception(), "a", new[] {"b"}); step.CheckIfNeeded().Returns(true); diff --git a/src/Recyclarr/Migration/MigrationExecutor.cs b/src/Recyclarr/Migration/MigrationExecutor.cs index bf483cb9..f5b7a6c0 100644 --- a/src/Recyclarr/Migration/MigrationExecutor.cs +++ b/src/Recyclarr/Migration/MigrationExecutor.cs @@ -1,21 +1,21 @@ -using Serilog; +using CliFx.Infrastructure; namespace Recyclarr.Migration; public class MigrationExecutor : IMigrationExecutor { - private readonly ILogger _log; + private readonly IConsole _console; private readonly List _migrationSteps; - public MigrationExecutor(IEnumerable migrationSteps, ILogger log) + public MigrationExecutor(IEnumerable migrationSteps, IConsole console) { - _log = log; + _console = console; _migrationSteps = migrationSteps.OrderBy(x => x.Order).ToList(); } public void PerformAllMigrationSteps() { - _log.Debug("Performing migration steps..."); + _console.Output.WriteLine("Performing migration steps..."); // ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator foreach (var step in _migrationSteps) @@ -36,6 +36,8 @@ public class MigrationExecutor : IMigrationExecutor { throw new MigrationException(e, step.Description, step.Remediation); } + + _console.Output.WriteLine($"Migrate: {step.Description}"); } } }