Skip to content

Commit

Permalink
(chocolateyGH-268)(spec) Added "before modify" integration test scena…
Browse files Browse the repository at this point in the history
…rios.

These scenarios verify that chocolateyBeforeModify.ps1 is executed on
the correct package version when appropriate.
  • Loading branch information
Richard J Foster authored and Richard J Foster committed Mar 9, 2016
1 parent 8dd9927 commit 7a34e23
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/chocolatey.tests.integration/scenarios/InstallScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
12 changes: 12 additions & 0 deletions src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down Expand Up @@ -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()
{
Expand Down
15 changes: 15 additions & 0 deletions src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 7a34e23

Please sign in to comment.