public void ShouldNotDeleteDirectoryWhereRetainedDeployedToSame()
        {
            var journalEntries = new List <JournalEntry>
            {
                fourDayOldDeployment,
                fourDayOldSameLocationDeployment,
                twoDayOldDeployment,
            };

            deploymentJournal.GetAllJournalEntries().Returns(journalEntries);
            fileSystem.FileExists(fourDayOldSameLocationDeployment.ExtractedFrom).Returns(true);
            fileSystem.DirectoryExists(fourDayOldSameLocationDeployment.ExtractedTo).Returns(true);

            const int days = 3;

            retentionPolicy.ApplyRetentionPolicy(policySet1, days, null);

            // Ensure the directories are the same
            Assert.AreEqual(twoDayOldDeployment.ExtractedTo, fourDayOldSameLocationDeployment.ExtractedTo);

            // The old directory was not removed...
            fileSystem.DidNotReceive().DeleteDirectory(Arg.Is <string>(s => s.Equals(fourDayOldSameLocationDeployment.ExtractedTo)));

            // ...despite being removed from the journal
            deploymentJournal.Received().RemoveJournalEntries(Arg.Is <IEnumerable <string> >(ids => ids.Contains(fourDayOldSameLocationDeployment.Id)));

            // and unique directory still removed
            fileSystem.Received().DeleteDirectory(Arg.Is <string>(s => s.Equals(fourDayOldDeployment.ExtractedTo)));
        }
        public void ShouldNotDeleteDeployFailedScriptAfterExecutionIfSpecialVariableIsSet()
        {
            deployment.Variables.Set(SpecialVariables.DeleteScriptsOnCleanup, false.ToString());
            var convention = CreateRollbackConvention("DeployFailed");

            convention.Cleanup(deployment);
            fileSystem.DidNotReceive().DeleteFile(TestEnvironment.ConstructRootedPath("App", "MyApp", "DeployFailed.ps1"), Arg.Any <FailureOptions>());
        }
Beispiel #3
0
        public void ShouldNotDeletePreDeployScriptAfterExecutionIfSpecialVariableIsSet()
        {
            deployment.Variables.Set(SpecialVariables.DeleteScriptsOnCleanup, false.ToString());
            var convention = CreateConvention("PreDeploy");

            convention.Install(deployment);
            scriptEngine.Received().Execute(Arg.Is <Script>(s => s.File == TestEnvironment.ConstructRootedPath("App", "MyApp", "PreDeploy.ps1")), deployment.Variables, runner);
            fileSystem.DidNotReceive().DeleteFile(TestEnvironment.ConstructRootedPath("App", "MyApp", "PreDeploy.ps1"), Arg.Any <FailureOptions>());
        }
Beispiel #4
0
        public void ShouldKeepDeploymentsForSpecifiedDays()
        {
            const int days = 3;

            retentionPolicy.ApplyRetentionPolicy(policySet1, days, null);

            // The older artifacts should have been removed
            fileSystem.Received().DeleteDirectory(fourDayOldDeployment.ExtractedTo);
            fileSystem.Received().DeleteFile(fourDayOldDeployment.ExtractedFrom, Arg.Any <DeletionOptions>());

            // The newer artifacts, and those from the non-matching policy-set, should have been kept
            // In other words, nothing but the matching deployment should have been removed
            fileSystem.DidNotReceive().DeleteDirectory(Arg.Is <string>(s => !s.Equals(fourDayOldDeployment.ExtractedTo)));
            fileSystem.DidNotReceive().DeleteFile(Arg.Is <string>(s => !s.Equals(fourDayOldDeployment.ExtractedFrom)), Arg.Any <DeletionOptions>());

            // The older entry should have been removed from the journal
            deploymentJournal.Received().RemoveJournalEntries(Arg.Is <IEnumerable <string> >(ids => ids.Count() == 1 && ids.Contains(fourDayOldDeployment.Id)));
        }
        public void ShouldNotRemoveCustomPostDeployScriptFileAfterRunningIfSpecialVariableIsSet()
        {
            deployment.Variables.Set(SpecialVariables.DeleteScriptsOnCleanup, false.ToString());
            const string stage      = DeploymentStages.PostDeploy;
            var          scriptName = ConfiguredScriptConvention.GetScriptName(stage, ScriptSyntax.PowerShell);
            var          scriptPath = Path.Combine(stagingDirectory, scriptName);

            variables.Set(scriptName, "blah blah");

            var convention = CreateConvention(stage);

            scriptEngine.Execute(Arg.Any <Script>(), variables, commandLineRunner).Returns(new CommandResult("", 0));
            convention.Install(deployment);

            fileSystem.DidNotReceive().DeleteFile(scriptPath, Arg.Any <FailureOptions>());
        }
Beispiel #6
0
        public void ShouldNotOverwriteScriptFileIfItExists()
        {
            const string deployStage = "BeforeDeploy";
            const string feature     = "doTheThing";
            var          scriptPath  = Path.Combine(stagingDirectory, FeatureScriptConvention.GetScriptName(feature, deployStage, "ps1"));

            Arrange(new List <string> {
                feature
            }, deployStage);
            fileSystem.FileExists(scriptPath).Returns(true);

            var convention = CreateConvention(deployStage);

            scriptEngine.Execute(scriptPath, variables, commandLineRunner).Returns(new CommandResult("", 0));
            convention.Install(deployment);

            fileSystem.DidNotReceive().OverwriteFile(scriptPath, Arg.Any <string>());
        }
Beispiel #7
0
 public void ShouldNotCopyFilesWhenCustomInstallationDirectoryNotSupplied()
 {
     CreateConvention().Install(deployment);
     fileSystem.DidNotReceive().CopyDirectory(Arg.Any <string>(), customInstallationDirectory);
 }