public void Load_file_migrations_with_file_loader_works() { // Arrange var loader = new FileMigrationLoader(new EvolveConfiguration { Locations = new[] { TestContext.Scripts1, TestContext.Scripts2, TestContext.Scripts1, TestContext.Scripts2 + "/PSG" } }); // Act var scripts = loader.GetMigrations().ToList(); // Assert Assert.Equal(8, scripts.Count); AssertMigration(scripts[0], "1.3.0", "V1_3_0__desc.sql", "desc"); AssertMigration(scripts[1], "1.3.1", "V1_3_1__desc.sql", "desc"); AssertMigration(scripts[2], "1.4.0", "V1_4_0__desc.sql", "desc"); AssertMigration(scripts[3], "1.5.0", "V1_5_0__desc.sql", "desc"); AssertMigration(scripts[4], "2.0.0", "V2_0_0__desc.sql", "desc"); AssertMigration(scripts[5], "2.4.0", "V2_4_0__desc.sql", "desc"); AssertMigration(scripts[6], "3.0.0", "v3_0_0__CI.sql", "CI"); AssertMigration(scripts[7], "3.0.1", "V3_0_1__CI.Sql", "CI");
public void Load_repeatable_file_migrations_with_file_loader_works() { // Arrange var loader = new FileMigrationLoader(new[] { TestContext.Scripts1, TestContext.Scripts2, TestContext.Scripts1, TestContext.Scripts2 + "/PSG" }); // Act var scripts = loader.GetRepeatableMigrations("R", "__", ".sql").ToList(); // Assert Assert.Equal(4, scripts.Count); AssertMigration(scripts[0], "R__desc_a.sql", "desc a"); AssertMigration(scripts[1], "R__desc_b.sql", "desc b"); AssertMigration(scripts[2], "R__desc_c.sql", "desc c"); AssertMigration(scripts[3], "r__desc_ci.sql", "desc ci"); void AssertMigration(MigrationScript migration, string name, string description) { Assert.Equal(MetadataType.RepeatableMigration, migration.Type); Assert.Null(migration.Version); Assert.Equal(name, migration.Name); Assert.Equal(description, migration.Description); } }
public void Load_file_migrations_with_file_loader_works() { // Arrange var loader = new FileMigrationLoader(new[] { TestContext.Scripts1, TestContext.Scripts2, TestContext.Scripts1, TestContext.Scripts2 + "/PSG" }); // Act var scripts = loader.GetMigrations("V", "__", ".sql").ToList(); // Assert Assert.Equal(8, scripts.Count); AssertMigration(scripts[0], "1.3.0", "V1_3_0__desc.sql", "desc"); AssertMigration(scripts[1], "1.3.1", "V1_3_1__desc.sql", "desc"); AssertMigration(scripts[2], "1.4.0", "V1_4_0__desc.sql", "desc"); AssertMigration(scripts[3], "1.5.0", "V1_5_0__desc.sql", "desc"); AssertMigration(scripts[4], "2.0.0", "V2_0_0__desc.sql", "desc"); AssertMigration(scripts[5], "2.4.0", "V2_4_0__desc.sql", "desc"); AssertMigration(scripts[6], "3.0.0", "v3_0_0__CI.sql", "CI"); AssertMigration(scripts[7], "3.0.1", "V3_0_1__CI.Sql", "CI"); void AssertMigration(MigrationScript migration, string version, string name, string description) { Assert.Equal(MetadataType.Migration, migration.Type); Assert.Equal(version, migration.Version.Label); Assert.Equal(name, migration.Name); Assert.Equal(description, migration.Description); } }
public void ValidateChecksum_should_work_with_old_checksum_version() { // Arrange FileMigrationLoader loader = new FileMigrationLoader(new[] { "Resources/LF_CRLF" }); // Assert foreach (FileMigrationScript script in loader.GetMigrations("V", "__", ".sql")) { script.ValidateChecksum(FallbackCheck(script.Path)); } }
public void When_duplicate_version_found_Throws_EvolveException() { var loader = new FileMigrationLoader(); Assert.Throws <EvolveConfigurationException>(() => loader.GetMigrations(new List <string> { TestContext.ResourcesFolder }, TestContext.SqlMigrationPrefix, TestContext.SqlMigrationSeparator, TestContext.SqlMigrationSuffix)); }
public void TestExistingChecksumsValid() { IList <IMigrationScript> scripts = new FileMigrationLoader().GetMigrations(new List <string> { "Resources/scripts." }, "V", "__", ".sql").ToList(); foreach (var migrationScript in scripts) { var script = (FileMigrationScript)migrationScript; Assert.Equal(CalculateChecksum(script.Path), script.CheckSum); } }
public void ValidateChecksum_should_work_with_old_checksum_version() { // Arrange FileMigrationLoader loader = new FileMigrationLoader(); // Assert foreach (FileMigrationScript script in loader.GetMigrations(new List <string> { "Resources/Scripts_SQL_3" }, "V", "__", ".sql")) { script.ValidateChecksum(FallbackCheck(script.Path)); } }
public void ValidateChecksum_should_work_with_old_checksum_version() { // Arrange var loader = new FileMigrationLoader(new EvolveConfiguration { Locations = new[] { "Resources/LF_CRLF" } }); // Assert foreach (FileMigrationScript script in loader.GetMigrations()) { script.ValidateChecksum(FallbackCheck(script.Path)); } }
public void TestSameMigrationMatchesWithNormalization() { IList <IMigrationScript> scripts = new FileMigrationLoader(normalizeLineEndingsForChecksum: true).GetMigrations(new List <string> { "Resources/scripts." }, "V", "__", ".sql").ToList(); IList <IMigrationScript> embedded = new EmbeddedResourceMigrationLoader(GetType().Assembly, normalizeLineEndingsForChecksum: true).GetMigrations(new List <string> { "Evolve.Test.Resources.scripts." }, "V", "__", ".sql").ToList(); Assert.Equal(2, scripts.Count); Assert.Equal(2, embedded.Count); Assert.True(scripts.Zip(embedded, Tuple.Create).All(AreEqual)); }
public void LoadFiles() { IList <IMigrationScript> scripts = new FileMigrationLoader().GetMigrations(new List <string> { "Resources/scripts." }, "V", "__", ".sql").ToList(); Assert.Equal(2, scripts.Count); var script = scripts.First(); Assert.Equal("V1_0_0__Test-Migration.sql", script.Name); Assert.Equal("Test-Migration", script.Description); Assert.NotNull(script.CheckSum); Assert.Equal("select 1;", script.LoadSqlStatements(null, "GO").FirstOrDefault()); }
public void GetMigrations_works() { var loader = new FileMigrationLoader(); var scripts = loader.GetMigrations(new List <string> { TestContext.ScriptsSQL1, TestContext.ScriptsSQL2, TestContext.ScriptsSQL1, TestContext.ScriptsSQL2 + @"\PSG" }, TestContext.SqlMigrationPrefix, TestContext.SqlMigrationSeparator, TestContext.SqlMigrationSuffix).ToList(); Assert.Equal("1.3.0", scripts[0].Version.Label); Assert.Equal("1.3.1", scripts[1].Version.Label); Assert.Equal("1.4.0", scripts[2].Version.Label); Assert.Equal("1.5.0", scripts[3].Version.Label); Assert.Equal("2.0.0", scripts[4].Version.Label); Assert.Equal("2.4.0", scripts[5].Version.Label); }
public void Load_file_migrations_works() { var loader = new FileMigrationLoader(new[] { TestContext.Scripts1, TestContext.Scripts2, TestContext.Scripts1, TestContext.Scripts2 + "/PSG" }); var scripts = loader.GetMigrations("V", "__", ".sql").ToList(); Assert.Equal("1.3.0", scripts[0].Version.Label); Assert.Equal("1.3.1", scripts[1].Version.Label); Assert.Equal("1.4.0", scripts[2].Version.Label); Assert.Equal("1.5.0", scripts[3].Version.Label); Assert.Equal("2.0.0", scripts[4].Version.Label); Assert.Equal("2.4.0", scripts[5].Version.Label); }
public void When_duplicate_version_found_Throws_EvolveException() { var loader = new FileMigrationLoader(new[] { TestContext.ResourcesFolder }); Assert.Throws <EvolveConfigurationException>(() => loader.GetMigrations("V", "__", ".sql")); }