Ejemplo n.º 1
0
        public void ShouldRunConfiguredScripts()
        {
            variables.Set(SpecialVariables.Package.EnabledFeatures, SpecialVariables.Features.CustomScripts);
            variables.Set(ConfiguredScriptConvention.GetScriptName(DeploymentStages.Deploy, "ps1"), "Write-Host 'The wheels on the bus go round...'");

            var result = DeployPackage("Acme.Web");

            result.AssertOutput("The wheels on the bus go round...");
        }
        public void ShouldThrowAnErrorIfAScriptExistsWithTheWrongType()
        {
            const string stage      = DeploymentStages.PostDeploy;
            var          scriptName = ConfiguredScriptConvention.GetScriptName(stage, ScriptSyntax.CSharp);

            variables.Set(scriptName, "blah blah");
            var    convention = CreateConvention(stage);
            Action exec       = () => convention.Install(deployment);

            exec.Should().Throw <CommandException>().WithMessage("CSharp scripts are not supported on this platform (PostDeploy)");
        }
Ejemplo n.º 3
0
        public void ShouldRemoveScriptFileAfterRunning()
        {
            const string stage      = DeploymentStages.PostDeploy;
            var          scriptName = ConfiguredScriptConvention.GetScriptName(stage, "ps1");
            var          scriptPath = Path.Combine(stagingDirectory, scriptName);

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

            var convention = CreateConvention(stage);

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

            fileSystem.Received().DeleteFile(scriptPath, Arg.Any <FailureOptions>());
        }
        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>());
        }
Ejemplo n.º 5
0
        public void ShouldRunScriptAtAppropriateStage()
        {
            const string stage      = DeploymentStages.PostDeploy;
            const string scriptBody = "lorem ipsum blah blah blah";
            var          scriptName = ConfiguredScriptConvention.GetScriptName(stage, "ps1");
            var          scriptPath = Path.Combine(stagingDirectory, scriptName);

            variables.Set(scriptName, scriptBody);

            var convention = CreateConvention(stage);

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

            fileSystem.Received().OverwriteFile(scriptPath, scriptBody);
            scriptEngine.Received().Execute(scriptPath, variables, commandLineRunner);
        }
Ejemplo n.º 6
0
        public void ShouldRunConfiguredScripts()
        {
            Variables.Set(SpecialVariables.Package.EnabledFeatures, SpecialVariables.Features.CustomScripts);

            if (CalamariEnvironment.IsRunningOnNix || CalamariEnvironment.IsRunningOnMac)
            {
                Variables.Set(ConfiguredScriptConvention.GetScriptName(DeploymentStages.Deploy, "sh"), "echo 'The wheels on the bus go round...'");
            }
            else
            {
                Variables.Set(ConfiguredScriptConvention.GetScriptName(DeploymentStages.Deploy, "ps1"), "Write-Host 'The wheels on the bus go round...'");
            }

            var result = DeployPackage();

            result.AssertOutput("The wheels on the bus go round...");
        }
        public void ShouldRunScriptAtAppropriateStage()
        {
            const string stage      = DeploymentStages.PostDeploy;
            const string scriptBody = "lorem ipsum blah blah blah";
            var          scriptName = ConfiguredScriptConvention.GetScriptName(stage, ScriptSyntax.PowerShell);
            var          scriptPath = Path.Combine(stagingDirectory, scriptName);
            var          script     = new Script(scriptPath);

            variables.Set(scriptName, scriptBody);

            var convention = CreateConvention(stage);

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

            fileSystem.Received().WriteAllBytes(scriptPath, Arg.Any <byte[]>());
            scriptEngine.Received().Execute(Arg.Is <Script>(s => s.File == scriptPath), variables, commandLineRunner);
        }