public void when_target_environment_is_not_provided_then_there_are_no_errors() { var migrationInfo = new MigrationInfo(direction: MigrationDirection.Up, scriptFolder: Some.String(), targetSchema: "testSchema", targetTablespace: "testTablespace", targetEnvironment: null, targetVersion: null); Assert.DoesNotThrow(() => _migrator.Migrate(Some.ConnectionInfo(), migrationInfo)); }
public void ensure_applied_scripts_repository_is_initialised_when_running_an_up_migration() { var migrationInfo = new MigrationInfo(direction: MigrationDirection.Up, scriptFolder: Some.String(), targetSchema: "testSchema", targetTablespace: "testTablespace", targetEnvironment: Some.ListOf(Some.String()), targetVersion: null); _migrator.Migrate(Some.ConnectionInfo(), migrationInfo); _mockAppliedScriptRespository.Verify(m => m.InitialiseAppliedScriptsTable("testSchema", "testTablespace")); }
public void all_supported_script_folders_are_scanned() { _migrator.Migrate(Some.ConnectionInfo(), Some.MigrationInfo()); foreach (var mockScriptScanner in _mockScriptScannerFactory.GetMocks()) { mockScriptScanner.Verify(m => m.Scan(It.IsAny <string>(), It.IsAny <string>()), Times.Once); } }
public void when_an_up_script_is_missing_a_corresponding_down_script_then_a_warning_is_displayed() { const string upScriptPath = "20150406_scriptpath"; _mockScriptScannerFactory.GetMock(ScriptFolders.Up).Setup(m => m.Scan(It.IsAny <string>(), It.IsAny <string>())).Returns(new[] { new Script(upScriptPath, 1) }); _migrator.Migrate(Some.ConnectionInfo(), Some.MigrationInfo()); _mockOutput.Verify(m => m.WriteLine("The following 'up' scripts do not have a corresponding 'down' script, any rollback may not work as expected:".Yellow())); _mockOutput.Verify(m => m.WriteLine(" {0}".FormatWith(upScriptPath).Yellow()), Times.Once()); }
public void when_there_are_applied_scripts_stored_in_the_target_database_then_those_can_be_retrieved_for_down_migrations() { const string downScriptPath = "RB_20150406_scriptpath"; _mockScriptScannerFactory.GetMock(ScriptFolders.Down).Setup(m => m.Scan(It.IsAny <string>(), It.IsAny <string>())).Returns(new[] { new Script(downScriptPath, 1) }); _migrator.Migrate(Some.ConnectionInfo(), new MigrationInfo(direction: MigrationDirection.Down, scriptFolder: Some.String(), targetSchema: "testSchema", targetTablespace: "testTablespace", targetEnvironment: Some.ListOf(Some.String()), targetVersion: null, useStored: true)); _mockAppliedScriptRespository.Verify(m => m.GetAppliedScripts("testSchema"), Times.Once); }