Skip to content

Commit

Permalink
(chocolateyGH-1133) autouninstaller - skip if package is missing
Browse files Browse the repository at this point in the history
When the package information comes back null, skip the uninstaller.
  • Loading branch information
ferventcoder committed Aug 29, 2017
1 parent df22c3a commit e480224
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,34 @@ public void should_log_why_it_skips_auto_uninstaller()
MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - No registry snapshot."), Times.Once);
}

[Fact]
public void should_not_call_command_executor()
{
commandExecutor.Verify(
c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()),
Times.Never);
}
}

public class when_package_is_missing : AutomaticUninstallerServiceSpecsBase
{
public override void Context()
{
base.Context();
packageInformation.Package = null;
}

public override void Because()
{
service.run(packageResult, config);
}

[Fact]
public void should_log_why_it_skips_auto_uninstaller()
{
MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - No package in package information."), Times.Once);
}

[Fact]
public void should_not_call_command_executor()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace chocolatey.infrastructure.app.services
using domain.installers;
using filesystem;
using infrastructure.commands;
using logging;
using results;

public class AutomaticUninstallerService : IAutomaticUninstallerService
Expand Down Expand Up @@ -83,6 +84,13 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
return;
}

var package = pkgInfo.Package;
if (package == null)
{
this.Log().Info(" Skipping auto uninstaller - No package in package information.");
return;
}

this.Log().Info(" Running auto uninstaller...");
if (WaitForCleanup)
{
Expand Down

0 comments on commit e480224

Please sign in to comment.