From 7a34e232ee94840458b93f38c6c936ee40f21a10 Mon Sep 17 00:00:00 2001 From: Richard J Foster Date: Sun, 19 Jul 2015 13:57:26 -0400 Subject: [PATCH] (GH-268)(spec) Added "before modify" integration test scenarios. These scenarios verify that chocolateyBeforeModify.ps1 is executed on the correct package version when appropriate. --- .../scenarios/InstallScenarios.cs | 12 ++++++++++++ .../scenarios/UninstallScenarios.cs | 12 ++++++++++++ .../scenarios/UpgradeScenarios.cs | 15 +++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs index 60f73bb1b4..f23b5ff8f1 100644 --- a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs @@ -101,6 +101,18 @@ public void should_contain_a_message_that_it_would_have_run_a_powershell_script( expectedMessage.ShouldBeTrue(); } + + [Fact] + public void should_not_contain_a_message_that_it_would_have_run_powershell_modification_script() + { + bool expectedMessage = false; + foreach (var message in MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null()) + { + if (message.Contains("chocolateyBeforeModify.ps1")) expectedMessage = true; + } + + expectedMessage.ShouldBeFalse(); + } } [Concern(typeof(ChocolateyInstallCommand))] diff --git a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs index ae7d19b2fb..29652b1414 100644 --- a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs @@ -103,6 +103,12 @@ public void should_contain_a_message_that_it_would_have_run_a_powershell_script( expectedMessage.ShouldBeTrue(); } + + [Fact] + public void should_contain_a_message_that_it_would_have_run_powershell_modification_script() + { + MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null().Any(p => p.Contains("chocolateyBeforeModify.ps1")).ShouldBeTrue(); + } } [Concern(typeof (ChocolateyUninstallCommand))] @@ -220,6 +226,12 @@ public void config_should_match_package_result_name() packageResult.Name.ShouldEqual(Configuration.PackageNames); } + [Fact] + public void should_have_executed_chocolateyBeforeModify_script() + { + MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null().Any(p => p.Contains("installpackage 1.0.0 Before Modification")).ShouldBeTrue(); + } + [Fact] public void should_have_executed_chocolateyUninstall_script() { diff --git a/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs b/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs index 15f455aaf0..2ba4db10fe 100644 --- a/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs @@ -303,6 +303,21 @@ public void should_match_the_upgrade_version_of_one_dot_one_dot_zero() _packageResult.Version.ShouldEqual("1.1.0"); } + [Fact] + public void should_have_executed_chocolateyBeforeModify_script_for_original_package() + { + MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null().Any(p => p.Contains("upgradepackage 1.0.0 Before Modification")).ShouldBeTrue(); + } + + [Fact] + public void should_have_executed_chocolateyBeforeModify_before_chocolateyInstall() + { + MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null() + .SkipWhile(p => !p.Contains("upgradepackage 1.0.0 Before Modification")) + .Any(p => p.EndsWith("upgradepackage 1.1.0 Installed")) + .ShouldBeTrue(); + } + [Fact] public void should_not_have_executed_chocolateyUninstall_script_for_original_package() {