Skip to content

Commit

Permalink
Adds test to ensure runner.Run throws if a migration throws.
Browse files Browse the repository at this point in the history
JudahGabriel committed Feb 15, 2024
1 parent 73d0cb1 commit 45c4c64
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion Raven.Migrations.Tests/RunnerTests.cs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
using Raven.Client.Documents.Indexes;
using Raven.TestDriver;
using Xunit;
using static System.Formats.Asn1.AsnWriter;

namespace Raven.Migrations.Tests
{
@@ -246,6 +247,17 @@ public void Can_call_migrations_that_are_not_direct_subclasses_of_Migration()
var development = session.Load<object>("migrated-using-BaseMigration");
development.Should().NotBeNull();
}

[Fact]
public void Failed_migrations_throw()
{
var options = GetMigrationOptions();
options.Profiles.Add("migration that throws exception");

using var store = GetDocumentStore();
var runner = new MigrationRunner(store, options, new ConsoleLogger());
Assert.Throws<System.Exception>(() => runner.Run());
}

private MigrationOptions GetMigrationOptions()
{
@@ -335,7 +347,18 @@ public class _has_problems__with_underscores___ : Migration
public override void Up()
{
}
}
}

[Migration(6, "migration that throws exception")]
public class MigrationThrowsException : Migration
{
public override void Up()
{
throw new System.Exception("This is failing migration");
}
}



public abstract class BaseMigration : Migration
{

0 comments on commit 45c4c64

Please sign in to comment.