Skip to content

Commit

Permalink
(chocolateyGH-268)(spec) Add scenarios verifying powershell script ex…
Browse files Browse the repository at this point in the history
…ecution.

While there appeared to be verification in the noop scenario, there did
not appear to be any verification in the regular case. These spec items
verify that the encapsulated package script was run by examining the
script output.
  • Loading branch information
Richard J Foster authored and ferventcoder committed Apr 9, 2016
1 parent dc69273 commit 515c695
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace chocolatey.tests.integration.scenarios
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -314,6 +315,12 @@ public void should_have_a_version_of_one_dot_zero_dot_zero()
{
packageResult.Version.ShouldEqual("1.0.0");
}

[Fact]
public void should_have_executed_chocolateyInstall_script()
{
MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null().Any(p => p.Contains("installpackage v1.0.0 has been installed")).ShouldBeTrue("Installpackage info message not seen. Info messages that were seen: {0}".format_with(string.Join(Environment.NewLine, MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null())));
}
}

[Concern(typeof(ChocolateyInstallCommand))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ public void config_should_match_package_result_name()
{
packageResult.Name.ShouldEqual(Configuration.PackageNames);
}

[Fact]
public void should_have_executed_chocolateyUninstall_script()
{
MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null().Any(p => p.EndsWith("installpackage 1.0.0 Uninstalled")).ShouldBeTrue();
}
}

[Concern(typeof (ChocolateyUninstallCommand))]
Expand Down
12 changes: 12 additions & 0 deletions src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,18 @@ public void should_match_the_upgrade_version_of_one_dot_one_dot_zero()
{
_packageResult.Version.ShouldEqual("1.1.0");
}

[Fact]
public void should_not_have_executed_chocolateyUninstall_script_for_original_package()
{
MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null().Any(p => p.EndsWith("upgradepackage 1.0.0 Uninstalled")).ShouldBeFalse();
}

[Fact]
public void should_have_executed_chocolateyInstall_script_for_new_package()
{
MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null().Any(p => p.EndsWith("upgradepackage 1.1.0 Installed")).ShouldBeTrue();
}
}

[Concern(typeof (ChocolateyUpgradeCommand))]
Expand Down

0 comments on commit 515c695

Please sign in to comment.