public void DoExecute_fails_on_not_existing_script() { // arrange IEnumerable<string> notExistingScripts = new List<string>() { "someScript.sql" }; _deploymentStep = new RunDbScriptsDeploymentStep(_dbScriptRunnerFake.Object, _DatabaseServerName, notExistingScripts); // act, assert Assert.Throws<FileNotFoundException>(() => _deploymentStep.PrepareAndExecute()); }
public void DoExecute_fails_on_nonversioned_script() { // arrange IEnumerable<DbScriptToRun> nonVersionedScript = new List<DbScriptToRun>() { new DbScriptToRun(DbVersion.FromString("1.0"), "TestData/NonVersionedScript/01.NonVersionedScript.sql") }; _deploymentStep = new RunDbScriptsDeploymentStep(_dbScriptRunnerFake.Object, _DatabaseServerName, nonVersionedScript); // act, assert Assert.Throws<DeploymentTaskException>(() => _deploymentStep.PrepareAndExecute()); }
protected override void DoPrepare() { EnvironmentInfo environmentInfo = GetEnvironmentInfo(); DbProjectInfo projectInfo = GetProjectInfo<DbProjectInfo>(); DbProjectConfiguration dbProjectConfiguration = environmentInfo.GetDbProjectConfiguration(projectInfo.Name); DatabaseServer databaseServer = environmentInfo.GetDatabaseServer(dbProjectConfiguration.DatabaseServerId); string databaseServerMachineName = databaseServer.MachineName; // create a step for downloading the artifacts var downloadArtifactsDeploymentStep = new DownloadArtifactsDeploymentStep( projectInfo, DeploymentInfo, GetTempDirPath(), _artifactsRepository); AddSubTask(downloadArtifactsDeploymentStep); // create a step for extracting the artifacts var extractArtifactsDeploymentStep = new ExtractArtifactsDeploymentStep( projectInfo, environmentInfo, DeploymentInfo, downloadArtifactsDeploymentStep.ArtifactsFilePath, GetTempDirPath(), _fileAdapter, _zipFileAdapter); AddSubTask(extractArtifactsDeploymentStep); // create a step for gathering scripts to run var gatherDbScriptsToRunDeploymentStep = new GatherDbScriptsToRunDeploymentStep( projectInfo.DbName, new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath), databaseServerMachineName, environmentInfo.Name, _dbVersionProvider); AddSubTask(gatherDbScriptsToRunDeploymentStep); // create a step for running scripts var runDbScriptsDeploymentStep = new RunDbScriptsDeploymentStep( GetScriptRunner(databaseServerMachineName), databaseServerMachineName, new DeferredEnumerable<DbScriptToRun>(() => gatherDbScriptsToRunDeploymentStep.ScriptsToRun)); AddSubTask(runDbScriptsDeploymentStep); }
protected override void DoPrepare() { EnvironmentInfo environmentInfo = GetEnvironmentInfo(); // create a step for downloading the artifacts var downloadArtifactsDeploymentStep = new DownloadArtifactsDeploymentStep( _artifactsRepository, _projectInfo, _projectConfigurationName, _projectConfigurationBuildId, GetTempDirPath()); AddSubTask(downloadArtifactsDeploymentStep); // create a step for extracting the artifacts var extractArtifactsDeploymentStep = new ExtractArtifactsDeploymentStep( environmentInfo, _projectInfo, _projectConfigurationName, _projectConfigurationBuildId, downloadArtifactsDeploymentStep.ArtifactsFilePath, GetTempDirPath()); AddSubTask(extractArtifactsDeploymentStep); // create a step for gathering scripts to run var gatherDbScriptsToRunDeploymentStep = new GatherDbScriptsToRunDeploymentStep( extractArtifactsDeploymentStep.BinariesDirPath, _projectInfo.DbName, environmentInfo.DatabaseServerMachineName, environmentInfo.Name, _dbVersionProvider); AddSubTask(gatherDbScriptsToRunDeploymentStep); // create a step for running scripts var runDbScriptsDeploymentStep = new RunDbScriptsDeploymentStep( GetScriptRunner(environmentInfo.DatabaseServerMachineName), environmentInfo.DatabaseServerMachineName, new DeferredEnumerable<string>(() => gatherDbScriptsToRunDeploymentStep.ScriptsToRun)); AddSubTask(runDbScriptsDeploymentStep); }
public void SetUp() { _dbScriptRunnerFake = new Mock<IDbScriptRunner>(MockBehavior.Loose); _deploymentStep = new RunDbScriptsDeploymentStep(_dbScriptRunnerFake.Object, _DatabaseServerName, _ScriptsToRun); }